Explorar el Código

Merge branch 'caiwu' of http://git.tjyourong.com.cn/ctop/adsp-boot into yumeng

# Conflicts:
#	jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java
#	module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java
yumeng hace 1 año
padre
commit
c74ec83332
Se han modificado 86 ficheros con 2187 adiciones y 374 borrados
  1. 3 0
      jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java
  2. 1 1
      jeecg-boot-module-system/src/main/resources/jeecg/jeecg_config.properties
  3. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/OauthAgentToken.java
  4. 15 0
      module-common/src/main/java/cn/com/ctop/common/module/entity/Project.java
  5. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java
  6. 6 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/OauthAgentTokenMapper.java
  7. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  8. 20 6
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml
  9. 6 11
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MailLogMapper.xml
  10. 11 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml
  11. 22 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/OauthAgentTokenMapper.xml
  12. 9 8
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml
  13. 8 0
      module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  14. 5 3
      module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java
  15. 4 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java
  16. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IOauthAgentTokenService.java
  17. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IRefreshTokenService.java
  18. 2 0
      module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java
  19. 85 11
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java
  20. 9 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/MaterialInfoServiceImpl.java
  21. 21 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/OauthAgentTokenServiceImpl.java
  22. 15 3
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/RefreshTokenServiceImpl.java
  23. 5 0
      module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java
  24. 183 0
      module-common/src/main/java/cn/com/ctop/common/module/vo/ByteDanceAdvertiserReportDTO.java
  25. 0 2
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceMaterialsLoadJob.java
  26. 3 0
      module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePlanLoadJob.java
  27. 87 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/DuxiaomanJob.java
  28. 35 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/ExternalMaterialCollectionJob.java
  29. 25 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouRefreshLiveTokenJob.java
  30. 3 2
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouYesterdayAgentReportJob.java
  31. 60 142
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoCreativeJob.java
  32. 0 45
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoVideoJob.java
  33. 12 15
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCreateCreativeJob.java
  34. 142 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouOrderLIstGetJob.java
  35. 28 0
      module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/SynchronousAccountTransactionJob.java
  36. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAdvertiserStrategyMapper.java
  37. 10 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAdvertiserStrategyMapper.xml
  38. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/IAiKuaishouAdvertiserStrategyService.java
  39. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAdvertiserStrategyServiceImpl.java
  40. 2 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageServiceImpl.java
  41. 72 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/Enums/KuaishouHourEnum.java
  42. 63 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/Enums/KuaishouMinSecEnum.java
  43. 276 6
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouRealTimeController.java
  44. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouGroup.java
  45. 199 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouSupplyChain.java
  46. 21 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaishouSupplyChainMapper.java
  47. 4 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml
  48. 67 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaishouSupplyChainMapper.xml
  49. 19 11
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/MaterialUploadTaskMapper.xml
  50. 1 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouAccountBudgetService.java
  51. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java
  52. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouRealTimeDataService.java
  53. 16 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouSupplyChainService.java
  54. 6 55
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java
  55. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/IKuaiShouCommentServiceImpl.java
  56. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouHistoryReportTaskServiceImpl.java
  57. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouReportDailyMaterialServiceImpl.java
  58. 6 1
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouAccountBudgetServiceImpl.java
  59. 49 5
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouRealTimeDataServiceImpl.java
  60. 134 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouSupplyChainServiceImpl.java
  61. 32 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/entity/KuaishouReportHourlyGroup.java
  62. 0 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouSupplyChainMapper.xml
  63. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaiShouGroupDailyReportServiceImpl.java
  64. 8 8
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaiShouDailyAgentServiceImpl.java
  65. 1 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouAudienceReportDailyServiceImpl.java
  66. 2 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouGroupExploreServiceImpl.java
  67. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyGroupServiceImpl.java
  68. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyImageServiceImpl.java
  69. 5 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportHourlyGroupServiceImpl.java
  70. 7 2
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/RuleKuaiShouPlanServiceImpl.java
  71. 120 0
      module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/utils/LinkUtils.java
  72. 15 3
      module-oa/src/main/java/cn/com/ctop/oa/modules/enums/DepartEnum.java
  73. 2 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/mapper/CtopAccountTransactionDayMapper.java
  74. 27 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/mapper/xml/CtopAccountTransactionDayMapper.xml
  75. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/mapper/xml/CtopAgentAccountMapper.xml
  76. 2 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/service/AgentManagementService.java
  77. 94 5
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/service/impl/AgentManagementServiceImpl.java
  78. 11 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceAdvertisePlan.java
  79. 3 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceImageInfoMapper.java
  80. 12 3
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceImageInfoMapper.xml
  81. 1 1
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/IBytedanceImageInfoService.java
  82. 5 2
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java
  83. 7 4
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceImageInfoServiceImpl.java
  84. 0 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/KuaishouSupplyChainMapper.xml
  85. 1 0
      module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/service/impl/ReportServiceImpl.java
  86. 1 1
      pom.xml

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

@@ -202,6 +202,9 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/kuaishou/batch/*", "anon");
         filterChainDefinitionMap.put("/dimension/kuaiShouDimensionAccount/*", "anon");
         filterChainDefinitionMap.put("/ai/projectCreate/*", "anon");
+        //获取快手实时组数据信息
+        filterChainDefinitionMap.put("/kuaishou/realTime/*", "anon");
+        filterChainDefinitionMap.put("/agent/*", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 1 - 1
jeecg-boot-module-system/src/main/resources/jeecg/jeecg_config.properties

@@ -1,5 +1,5 @@
 #code_generate_project_path
-project_path=D:\\module
+project_path=/Users/yumeng/module
 #bussi_package[User defined]
 bussi_package=cn.com.ctop
 #default code path

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/OauthAgentToken.java

@@ -76,6 +76,11 @@ public class OauthAgentToken {
     @Excel(name = "代理商类型 0:三方代理商 1:本代理商", width = 15)
     @ApiModelProperty(value = "代理商类型 0:三方代理商 1:本代理商")
     private Integer agentType;
+
+
+    private  Long appId;
+    private String secret;
+
     /**
      * 创建时间
      */

+ 15 - 0
module-common/src/main/java/cn/com/ctop/common/module/entity/Project.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.common.module.entity;
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
@@ -116,9 +117,15 @@ public class Project {
     private Date updateTime;
 
 
+    //优化目标出价类型
     private String bidType;
+
+    //转化目标
     private String ocpxActionType;
 
+    //深度转化目标
+    private String deepConversionType;
+
     @TableField(exist = false)
     private String responsibleId_dictText; // 运营负责人
 
@@ -135,4 +142,12 @@ public class Project {
     private Integer needExamine;
     @TableField(exist = false)
     private String supplierCode_dictText;
+
+    //转化目标
+    @TableField(exist = false)
+    private JSONArray ocpxActionTypeArray;
+
+    //深度转化目标
+    @TableField(exist = false)
+    private JSONArray deepConversionTypeArray;
 }

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/MaterialInfoMapper.java

@@ -50,5 +50,9 @@ public interface MaterialInfoMapper extends BaseMapper<MaterialInfo> {
 
     void updateByteDanceByCode(@Param("code") String code);
 
+    List<String> getDuxiaomanMaterialInfoByStatus(@Param("status") Integer status);
+
+    List<String> getDuxiaomanMaterialInfoByTime();
+
     // List<MaterialInfo> getListByParams(String tagCode, String type, Integer status, String materialName, String code, String startDate, String endDate, List<Long> projectIds, String ascription, String clipId, String shotId, String planId, Integer offlineFlag);
 }

+ 6 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/OauthAgentTokenMapper.java

@@ -2,6 +2,9 @@ package cn.com.ctop.common.module.mapper;
 
 import cn.com.ctop.common.module.entity.OauthAgentToken;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * 代理商token
@@ -12,4 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface OauthAgentTokenMapper extends BaseMapper<OauthAgentToken> {
 
+    List<OauthAgentToken> getLiveKuaiShouAgentList(@Param("mediaId") Integer mediaId);
+
+    int updateLiveById(OauthAgentToken updateAgentToken);
 }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -62,4 +62,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     List<Long> queryAutomaticAccounts(@Param("projectId") Long projectId);
 
     List<Long> getIdList();
+
+    List<String> getAccountListByProjectV2(@Param("list") List<Long> list );
 }

+ 20 - 6
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/CtopOauthTokenMapper.xml

@@ -89,12 +89,26 @@
 
 
     <select id="selectKuaiShouToken" resultType="cn.com.ctop.common.module.entity.CtopOauthToken">
-        select  t1.*
-        from ctop_oauth_token t1
-        left join ctop_user_allocation t2
-        on t1.account_id = t2.account_id
-        where t2.account_status = 0
-        and t1.media_id = 2
+    SELECT
+	t1.id AS 'id',
+	t1.media_id AS 'mediaId',
+	t1.advertiser_id AS 'advertiser_id',
+	t1.account_id AS 'accountId',
+	( CASE WHEN t3.access_token IS NOT NULL THEN t3.access_token ELSE t1.access_token END ) AS 'accessToken',
+	( CASE WHEN t3.refresh_token IS NOT NULL THEN t3.refresh_token ELSE t1.refresh_token END ) AS 'refreshToken',
+	t1.agent_type AS 'agentType',
+	t1.app_id AS 'appId',
+	t1.access_token_expires_in as 'accessTokenExpiresIn',
+	t1.refresh_token_expires_in as 'refreshTokenExpiresIn',
+	t1.create_time as 'createTime',
+	t1.update_time as 'updateTime'
+	FROM
+	ctop_oauth_token t1
+	LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+	LEFT JOIN ctop_oauth_agent_token t3 ON t1.app_id = t3.app_id
+    WHERE
+	t2.account_status = 0
+	AND t1.media_id = 2;
 
     </select>
 

+ 6 - 11
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MailLogMapper.xml

@@ -28,17 +28,12 @@
 
 
     <select id="selectWeiXinIdList" resultType="com.alibaba.fastjson.JSONObject">
-     select
-     t2.wexin_id,t2.corp_id
-     from
-     ctop_project_member t1
-     left join ctop_corp_wexin_user t2
-     on t1.user_id = t2.user_id
-     LEFT JOIN sys_user t3
-     on  t1.user_id = t3.id
-     where t1.project_id = #{projectId}
-     and t3.`status` = 1
-     and t2.wexin_id != ''
+     select t2.wexin_id, t2.corp_id
+from ctop_user_allocation t1
+         left join ctop_corp_wexin_user t2 on t1.user_id = t2.user_id
+where t1.project_id = #{projectId}
+  and t1.account_status = 0
+group by t1.user_id
     </select>
 
     <select id="getWChatIdByUserId" resultType="com.alibaba.fastjson.JSONObject">

+ 11 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/MaterialInfoMapper.xml

@@ -205,6 +205,17 @@
          GROUP BY `code`
 
     </select>
+
+    <select id="getDuxiaomanMaterialInfoByStatus" resultType="java.lang.String">
+        SELECT id FROM `ctop_duxiaoman_material_info`
+        WHERE `status` = #{status}
+    </select>
+
+    <select id="getDuxiaomanMaterialInfoByTime" resultType="java.lang.String">
+        SELECT id FROM ctop_duxiaoman_material_info
+        WHERE confirm_time >= DATE_FORMAT(now(), '%Y-%m-%d')
+    </select>
+
     <select id="getBytedanceCountByCode" resultType="java.lang.Integer">
         SELECT count(1)  from  ctop_bytedance_video_info WHERE signature = #{code}
     </select>

+ 22 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/OauthAgentTokenMapper.xml

@@ -2,4 +2,26 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.common.module.mapper.OauthAgentTokenMapper">
 
+    <select id="getLiveKuaiShouAgentList" resultType="cn.com.ctop.common.module.entity.OauthAgentToken">
+        select *
+        from ruixuan.agent_token
+        where media_id = #{mediaId}
+    </select>
+
+    <update id="updateLiveById">
+        UPDATE
+        ruixuan.agent_token
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="mediaId != null">media_id = #{mediaId},</if>
+            <if test="agentId != null">agent_id = #{agentId},</if>
+            <if test="accessToken != null">access_token = #{accessToken},</if>
+            <if test="accessTokenExpiresIn != null">access_token_expires_in = #{accessTokenExpiresIn},</if>
+            <if test="refreshToken != null">refresh_token = #{refreshToken},</if>
+            <if test="refreshTokenExpiresIn != null">refresh_token_expires_in = #{refreshTokenExpiresIn},</if>
+            <if test="agentType != null">agent_type = #{agentType},</if>
+            <if test="appId != null">app_id = #{appId},</if>
+            <if test="secret != null">secret = #{secret},</if>
+        </trim>
+        WHERE id = #{id}
+    </update>
 </mapper>

+ 9 - 8
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProjectMapper.xml

@@ -11,14 +11,15 @@
     </select>
 
     <select id="getWarningInfoByProjectId" resultType="com.alibaba.fastjson.JSONObject">
-     select
-     id projectId,
-     project_name projectName,
-     max_bid maxBid,
-     bid_type bidType,
-     ocpx_action_type ocpxActionType
-     from ctop_project
-     where id = #{projectId}
+        select
+            id projectId,
+            project_name projectName,
+            max_bid maxBid,
+            bid_type bidType,
+            ocpx_action_type ocpxActionType,
+            deep_conversion_type deepConversionType
+        from ctop_project
+        where id = #{projectId}
     </select>
 
     <select id="querySupplierCodeById" resultType="java.lang.String">

+ 8 - 0
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -243,5 +243,13 @@
         where status = 0
 
     </select>
+    <select id="getAccountListByProjectV2" resultType="java.lang.String" parameterType="java.lang.Long">
+        SELECT  account_id  FROM ctop_user_allocation where project_id
+        in
+         <foreach collection="list" item="list" separator="," open="(" close=")">
+        #{list}
+    </foreach>
+
+    </select>
 
 </mapper>

+ 5 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/ICtopOauthTokenService.java

@@ -38,15 +38,17 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
 
     CtopOauthToken selectOneByMediaId(String platformTypeKuaishou);
 
-    void getKuaiShouAgentRefreshToken(Long agentId, String accessToken, String refreshToken);
+    void getKuaiShouAgentRefreshToken(String id ,Long agentId, String accessToken, String refreshToken, Long appId, String secret);
 
     /**
-     *查询 快手 有效规则帐户token
+     * 查询 快手 有效规则帐户token
      */
     List<CtopOauthToken> queryKsValidRuleAccountsToken();
 
     /**
-     *查询 头条 有效规则帐户token
+     * 查询 头条 有效规则帐户token
      */
     List<CtopOauthToken> queryTtValidRuleAccountsToken();
+
+    void getLiveKuaiShouAgentRefreshToken(String id, String accessToken, String refreshToken, Long appId, String secret);
 }

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IMaterialInfoService.java

@@ -94,4 +94,8 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
     Integer getBytedanceCountByCode(String s);
 
     void updateByteDanceByCode(String s);
+
+    List<String> getDuxiaomanMaterialInfoByStatus(Integer status);
+
+    List<String> getDuxiaomanMaterialInfoByTime();
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IOauthAgentTokenService.java

@@ -3,6 +3,8 @@ package cn.com.ctop.common.module.service;
 import cn.com.ctop.common.module.entity.OauthAgentToken;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * @Description: 代理商token
  * @Author: jeecg-boot
@@ -11,4 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IOauthAgentTokenService extends IService<OauthAgentToken> {
 
+    OauthAgentToken getTokenByAppId(Long appId);
+
+    List<OauthAgentToken> getLiveKuaiShouAgentList(Integer mediaId);
 }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IRefreshTokenService.java

@@ -6,4 +6,6 @@ public interface IRefreshTokenService {
     void byteDanceRefresh(String accountId);
 
     void getKuaiShouAgentRefresh();
+
+    void getLiveKuaiShouAgentRefresh();
 }

+ 2 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -69,4 +69,6 @@ public interface IUserAllocationService extends IService<UserAllocation> {
     List<Long> queryAutomaticAccounts(Long projectId);
 
     List<Long> getIdList();
+
+    List<String> getAccountListByProjectV2( List<Long> list);
 }

+ 85 - 11
module-common/src/main/java/cn/com/ctop/common/module/service/impl/CtopOauthTokenServiceImpl.java

@@ -5,21 +5,20 @@ import cn.com.ctop.common.module.entity.OauthAgentToken;
 import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
 import cn.com.ctop.common.module.mapper.OauthAgentTokenMapper;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
+import cn.com.ctop.common.module.service.IOauthAgentTokenService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.HttpUtils;
-import cn.com.ctop.common.module.utils.PropertiesUtils;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xxl.job.core.context.XxlJobHelper;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.*;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 /**
  * @Description: oauth授权码
@@ -45,13 +44,22 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
     private CtopOauthTokenMapper ctopOauthTokenMapper;
     @Resource
     private OauthAgentTokenMapper agentTokenMapper;
+    @Autowired
+    private IOauthAgentTokenService agentTokenService;
 
     @Override
     public CtopOauthToken getOauthTokenByAccountId(String accountId) {
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("account_id", accountId).orderByDesc("create_time");
         queryWrapper.last("limit 1");
-        return this.getOne(queryWrapper);
+        CtopOauthToken one = this.getOne(queryWrapper);
+        if (one.getMediaId().equals("2") || one.getMediaId().equals("4")) {
+            OauthAgentToken tokenByAppId = agentTokenService.getTokenByAppId(one.getAppId());
+            if (!Check.isNull(tokenByAppId)) {
+                one.setAccessToken(tokenByAppId.getAccessToken());
+            }
+        }
+        return one;
     }
 
 
@@ -60,7 +68,14 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("account_id", accountId).orderByDesc("create_time");
         queryWrapper.last("limit 1");
-        return this.getOne(queryWrapper);
+        CtopOauthToken one = this.getOne(queryWrapper);
+        if (one.getMediaId().equals("2") || one.getMediaId().equals("4")) {
+            OauthAgentToken tokenByAppId = agentTokenService.getTokenByAppId(one.getAppId());
+            if (!Check.isNull(tokenByAppId)) {
+                one.setAccessToken(tokenByAppId.getAccessToken());
+            }
+        }
+        return one;
     }
 
     /**
@@ -200,6 +215,7 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
 
     @Override
     public List<CtopOauthToken> selectKuaiShouToken() {
+
         return ctopOauthTokenMapper.selectKuaiShouToken();
     }
 
@@ -248,15 +264,72 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
     }
 
     @Override
-    public void getKuaiShouAgentRefreshToken(Long agentId, String accessToken, String refreshToken) {
+    public void getKuaiShouAgentRefreshToken(String id, Long agentId, String accessToken, String refreshToken, Long appId, String secret) {
         log.info("快手刷新token入参,token:{},refreshToken:{}", accessToken, refreshToken);
         String url = kuaishouApiUrl + "/rest/openapi/oauth2/authorize/refresh_token";
         Map<String, String> headers = new HashMap<>();
         headers.put("Content-Type", " application/json");
         Map<String, Object> param = new HashMap<>();
 
-        param.put("app_id", PropertiesUtils.getConfig("kuaishou_appid"));
-        param.put("secret", PropertiesUtils.getConfig("kuaishou_secret"));
+        param.put("app_id", appId);
+        param.put("secret", secret);
+        param.put("refresh_token", refreshToken);
+        try {
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            log.info("快手刷新代理商token返回结果:{}", refreshToken);
+            if (Check.isNull(resultJson)) {
+                log.error("快手刷新代理商token返回结果为空,token:{}", accessToken);
+                return;
+            }
+            Integer code = resultJson.getInteger("code");
+            if (null == code || code != 0) {
+                log.error("快手刷新代理商token失败,token:{},result:{}", accessToken, resultJson);
+                return;
+            }
+            JSONObject dataJson = resultJson.getJSONObject("data");
+            if (null == dataJson) {
+                log.error("快手刷新代理商token失败,token:{},result:{}", accessToken, resultJson);
+                return;
+            }
+
+           /* QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
+            agentTokenQueryWrapper.eq("id", id);*/
+            OauthAgentToken updateAgentToken = new OauthAgentToken();
+            updateAgentToken.setId(id);
+            updateAgentToken.setAccessToken(dataJson.getString("access_token"));
+            updateAgentToken.setRefreshToken(dataJson.getString("refresh_token"));
+            long accessTokenExpireIn = dataJson.getLong("access_token_expires_in") * 1000L;
+            long now = System.currentTimeMillis();
+            Date accessTokenExpireInDate = new Date(now + accessTokenExpireIn);
+            updateAgentToken.setAccessTokenExpiresIn(accessTokenExpireInDate);
+            long refreshTokenExpireIn = dataJson.getLong("refresh_token_expires_in") * 1000L;
+            Date refreshTokenExpireInDate = new Date(now + refreshTokenExpireIn);
+            updateAgentToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
+            updateAgentToken.setUpdateTime(new Date());
+            int update = agentTokenMapper.updateById(updateAgentToken);
+            if (update > 0) {
+                log.info("刷新代理商token完成");
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            log.error("快手刷新代理商token失败,token{}", accessToken);
+        }
+
+
+    }
+
+
+    @Override
+    public void getLiveKuaiShouAgentRefreshToken(String id , String accessToken, String refreshToken, Long appId, String secret) {
+        log.info("快手刷新token入参,token:{},refreshToken:{}", accessToken, refreshToken);
+        String url = kuaishouApiUrl + "/rest/openapi/oauth2/authorize/refresh_token";
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", " application/json");
+        Map<String, Object> param = new HashMap<>();
+
+        param.put("app_id", appId);
+        param.put("secret", secret);
         param.put("refresh_token", refreshToken);
         try {
             String result = HttpUtils.httpPostRequest(url, param, headers);
@@ -277,9 +350,10 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
                 return;
             }
 
-            QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
-            agentTokenQueryWrapper.eq("agent_id", agentId);
+           /* QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
+            agentTokenQueryWrapper.eq("id", id);*/
             OauthAgentToken updateAgentToken = new OauthAgentToken();
+            updateAgentToken.setId(id);
             updateAgentToken.setAccessToken(dataJson.getString("access_token"));
             updateAgentToken.setRefreshToken(dataJson.getString("refresh_token"));
             long accessTokenExpireIn = dataJson.getLong("access_token_expires_in") * 1000L;
@@ -290,7 +364,7 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
             Date refreshTokenExpireInDate = new Date(now + refreshTokenExpireIn);
             updateAgentToken.setRefreshTokenExpiresIn(refreshTokenExpireInDate);
             updateAgentToken.setUpdateTime(new Date());
-            int update = agentTokenMapper.update(updateAgentToken, agentTokenQueryWrapper);
+            int update = agentTokenMapper.updateLiveById(updateAgentToken);
             if (update > 0) {
                 log.info("刷新代理商token完成");
             }

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

@@ -890,6 +890,15 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
         materialInfoMapper.updateByteDanceByCode(s);
     }
 
+    @Override
+    public List<String> getDuxiaomanMaterialInfoByStatus(Integer status) {
+        return baseMapper.getDuxiaomanMaterialInfoByStatus(status);
+    }
+
+    @Override
+    public List<String> getDuxiaomanMaterialInfoByTime() {
+        return baseMapper.getDuxiaomanMaterialInfoByTime();
+    }
 
     @Override
     public JSONArray getIdListByProject(Long projectId) {

+ 21 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/OauthAgentTokenServiceImpl.java

@@ -3,9 +3,13 @@ package cn.com.ctop.common.module.service.impl;
 import cn.com.ctop.common.module.entity.OauthAgentToken;
 import cn.com.ctop.common.module.mapper.OauthAgentTokenMapper;
 import cn.com.ctop.common.module.service.IOauthAgentTokenService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.util.List;
+
 /**
  * 代理商token
  *
@@ -16,4 +20,21 @@ import org.springframework.stereotype.Service;
 @Service
 public class OauthAgentTokenServiceImpl extends ServiceImpl<OauthAgentTokenMapper, OauthAgentToken> implements IOauthAgentTokenService {
 
+    @Resource
+    private OauthAgentTokenMapper mapper;
+
+
+    @Override
+    public OauthAgentToken getTokenByAppId(Long appId) {
+        QueryWrapper<OauthAgentToken> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("app_id", appId);
+        queryWrapper.last("limit 1");
+        OauthAgentToken one = this.getOne(queryWrapper);
+        return one;
+    }
+
+    @Override
+    public List<OauthAgentToken> getLiveKuaiShouAgentList(Integer mediaId) {
+        return mapper.getLiveKuaiShouAgentList(mediaId);
+    }
 }

+ 15 - 3
module-common/src/main/java/cn/com/ctop/common/module/service/impl/RefreshTokenServiceImpl.java

@@ -88,12 +88,24 @@ public class RefreshTokenServiceImpl implements IRefreshTokenService {
         List<OauthAgentToken> list = agentTokenService.list(agentTokenQueryWrapper);
         if (!Check.isNull(list)) {
             for (OauthAgentToken agentToken : list) {
-                oauthTokenService.getKuaiShouAgentRefreshToken(agentToken.getAgentId(), agentToken.getAccessToken(), agentToken.getRefreshToken());
-
+                oauthTokenService.getKuaiShouAgentRefreshToken(agentToken.getId(),agentToken.getAgentId(), agentToken.getAccessToken(), agentToken.getRefreshToken(),agentToken.getAppId(),agentToken.getSecret());
             }
-
         }
+    }
 
 
+    /**
+     * 获取所有token
+     *
+     * @return
+     */
+    @Override
+    public void getLiveKuaiShouAgentRefresh() {
+        List<OauthAgentToken> list = agentTokenService.getLiveKuaiShouAgentList(2);
+        if (!Check.isNull(list)) {
+            for (OauthAgentToken agentToken : list) {
+                oauthTokenService.getLiveKuaiShouAgentRefreshToken(agentToken.getId(), agentToken.getAccessToken(), agentToken.getRefreshToken(),agentToken.getAppId(),agentToken.getSecret());
+            }
+        }
     }
 }

+ 5 - 0
module-common/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -225,4 +225,9 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
     public List<Long> getIdList() {
         return userAllocationMapper.getIdList();
     }
+
+    @Override
+    public List<String> getAccountListByProjectV2(List<Long> list) {
+        return userAllocationMapper.getAccountListByProjectV2(list);
+    }
 }

+ 183 - 0
module-common/src/main/java/cn/com/ctop/common/module/vo/ByteDanceAdvertiserReportDTO.java

@@ -3,6 +3,8 @@ package cn.com.ctop.common.module.vo;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
 
 @Data
 public class ByteDanceAdvertiserReportDTO implements Serializable {
@@ -12,4 +14,185 @@ public class ByteDanceAdvertiserReportDTO implements Serializable {
     private Integer pageSize;
     private Integer page;
     private String timeGranularity;
+
+
+
+    private List<String> fields;
+
+
+
+    public List<String> getFieldsList(){
+        List<String> fields = new ArrayList<>();
+        fields.add("cost");
+        fields.add("show");
+        fields.add("avg_show_cost");
+        fields.add("avg_click_cost");
+        fields.add("click");
+        fields.add("ctr");
+        fields.add("convert");
+        fields.add("convert_cost");
+        fields.add("convert_rate");
+        fields.add("deep_convert");
+        fields.add("deep_convert_cost");
+        fields.add("deep_convert_rate");
+        fields.add("attribution_convert");
+        fields.add("attribution_convert_cost");
+        fields.add("attribution_deep_convert");
+        fields.add("attribution_deep_convert_cost");
+        fields.add("download_start");
+        fields.add("download_start_cost");
+        fields.add("download_start_rate");
+        fields.add("download_finish");
+        fields.add("download_finish_cost");
+        fields.add("download_finish_rate");
+        fields.add("install_finish");
+        fields.add("install_finish_cost");
+        fields.add("install_finish_rate");
+        fields.add("active");
+        fields.add("active_cost");
+        fields.add("active_rate");
+        fields.add("register");
+        fields.add("active_register_cost");
+        fields.add("active_register_rate");
+        fields.add("attribution_next_day_open_cnt");
+        fields.add("attribution_next_day_open_cost");
+        fields.add("attribution_next_day_open_rate");
+        fields.add("next_day_open");
+        fields.add("game_addiction");
+        fields.add("game_addiction_cost");
+        fields.add("game_addiction_rate");
+        fields.add("pay_count");
+        fields.add("active_pay_cost");
+        fields.add("active_pay_rate");
+        fields.add("game_pay_count");
+        fields.add("game_pay_cost");
+        fields.add("attribution_game_pay_7d_count");
+        fields.add("attribution_game_pay_7d_cost");
+        fields.add("attribution_active_pay_7d_per_count");
+        fields.add("loan_completion");
+        fields.add("loan_completion_cost");
+        fields.add("loan_completion_rate");
+        fields.add("pre_loan_credit");
+        fields.add("pre_loan_credit_cost");
+        fields.add("loan_credit");
+        fields.add("loan_credit_cost");
+        fields.add("loan_credit_rate");
+        fields.add("in_app_uv");
+        fields.add("in_app_detail_uv");
+        fields.add("in_app_cart");
+        fields.add("in_app_pay");
+        fields.add("in_app_order");
+        fields.add("phone");
+        fields.add("form");
+        fields.add("map_search");
+        fields.add("button");
+        fields.add("view");
+        fields.add("download");
+        fields.add("qq");
+        fields.add("lottery");
+        fields.add("vote");
+        fields.add("message");
+        fields.add("redirect");
+        fields.add("shopping");
+        fields.add("consult");
+        fields.add("wechat");
+        fields.add("wechat_login_count");
+        fields.add("attribution_wechat_login_30d_count");
+        fields.add("wechat_login_cost");
+        fields.add("attribution_wechat_login_30d_cost");
+        fields.add("wechat_first_pay_count");
+        fields.add("attribution_wechat_first_pay_30d_count");
+        fields.add("wechat_first_pay_cost");
+        fields.add("attribution_wechat_first_pay_30d_cost");
+        fields.add("wechat_first_pay_rate");
+        fields.add("attribution_wechat_first_pay_30d_rate");
+        fields.add("wechat_pay_amount");
+        fields.add("attribution_wechat_pay_30d_amount");
+        fields.add("attribution_wechat_pay_30d_roi");
+        fields.add("phone_connect");
+        fields.add("phone_confirm");
+        fields.add("phone_effective");
+        fields.add("consult_effective");
+        fields.add("coupon");
+        fields.add("coupon_single_page");
+        fields.add("redirect_to_shop");
+        fields.add("poi_address_click");
+        fields.add("poi_collect");
+        fields.add("luban_order_cnt");
+        fields.add("luban_order_stat_amount");
+        fields.add("luban_order_roi");
+        fields.add("luban_live_enter_cnt");
+        fields.add("live_watch_one_minute_count");
+        fields.add("luban_live_follow_cnt");
+        fields.add("live_fans_club_join_cnt");
+        fields.add("luban_live_comment_cnt");
+        fields.add("luban_live_share_cnt");
+        fields.add("luban_live_gift_cnt");
+        fields.add("luban_live_gift_amount");
+        fields.add("luban_live_slidecart_click_cnt");
+        fields.add("luban_live_click_product_cnt");
+        fields.add("luban_live_pay_order_count");
+        fields.add("luban_live_pay_order_stat_cost");
+        //fields.add("live_pay_order_cost_per_order");
+        fields.add("total_play");
+        fields.add("valid_play");
+        fields.add("valid_play_cost");
+        fields.add("valid_play_rate");
+        fields.add("play_25_feed_break");
+        fields.add("play_50_feed_break");
+        fields.add("play_100_feed_break");
+        //fields.add("play_25_feed_break_rate");
+        //fields.add("play_50_feed_break_rate");
+        //fields.add("play_100_feed_break_rate");
+        //fields.add("play_75_feed_break_rate");
+        fields.add("average_play_time_per_play");
+        //fields.add("play_over");
+        fields.add("play_over_rate");
+        fields.add("wifi_play_rate");
+        fields.add("wifi_play");
+        fields.add("card_show");
+        //fields.add("play_duration_2s_rate");
+        //fields.add("play_duration_3s_rate");
+        //fields.add("play_duration_5s_rate");
+        //fields.add("play_duration_10s_rate");
+        fields.add("advanced_creative_phone_click");
+        fields.add("advanced_creative_counsel_click");
+        fields.add("advanced_creative_form_click");
+        fields.add("advanced_creative_coupon_addition");
+        fields.add("advanced_creative_form_submit");
+        fields.add("share");
+        fields.add("comment");
+        fields.add("like");
+        fields.add("follow");
+        //fields.add("dislike");
+        //fields.add("report");
+        fields.add("message_action");
+        fields.add("home_visited");
+        fields.add("ies_challenge_click");
+        fields.add("ies_music_click");
+        fields.add("location_click");
+        fields.add("click_download");
+        fields.add("click_call_dy");
+        fields.add("click_shopwindow");
+        fields.add("click_website");
+        fields.add("click_landing_page");
+        //fields.add("interact_per_cost");
+        //fields.add("convert_show_rate");
+        //fields.add("cpc");
+        //fields.add("cpm");
+        //fields.add("cpa");
+        fields.add("submit_certification_count");
+        fields.add("approval_count");
+        fields.add("first_order_count");
+        fields.add("first_rental_order_count");
+        fields.add("commute_first_pay_count");
+        fields.add("live_component_click_count");
+        fields.add("live_component_click_cost");
+        fields.add("live_component_click_rate");
+        return fields;
+
+    }
+
+
+
 }

+ 0 - 2
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedanceMaterialsLoadJob.java

@@ -57,8 +57,6 @@ public class BytedanceMaterialsLoadJob {
         } catch (InterruptedException e) {
             e.printStackTrace();
         }
-        //修改图片类型
-        imageInfoService.updateType();
         XxlJobHelper.log("物料数据同步完成");
     }
 }

+ 3 - 0
module-job-bytedance/src/main/java/cn/com/ctop/job/bytedance/handler/BytedancePlanLoadJob.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
 import com.xxl.job.core.context.XxlJobHelper;
 import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -13,6 +14,7 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Component
+@Slf4j
 public class BytedancePlanLoadJob {
     @Autowired
     private ICtopOauthTokenService tokenService;
@@ -27,6 +29,7 @@ public class BytedancePlanLoadJob {
     @XxlJob("bytedancePlanLoadJob")
     public void execute() throws Exception {
         //1:查询当日数据
+        log.info("============获取头条全量计划=================");
         List<CtopOauthToken> tokens = tokenService.selectToutiaoToken();
         tokens.forEach(token -> executorService.submit(() -> advertiserDataService.getAdvertiserPlan(token, "", null, null)));
         XxlJobHelper.log("头条全量计划数据获取完成");

+ 87 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/DuxiaomanJob.java

@@ -0,0 +1,87 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.service.IMaterialInfoService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Component
+public class DuxiaomanJob {
+
+    @Value("${xxl-job.requestUrl}")
+    private String jobUrl;
+
+    @Autowired
+    private IMaterialInfoService materialInfoService;
+
+    /**
+     * 将1-待上传状态de素材 进行 上传媒体
+     */
+    @XxlJob("uploadMaterialJob")
+    public void uploadMaterial() throws InterruptedException {
+        String url = jobUrl + "/jeecg-boot/duxiaoman/materialInfo/uploadMaterial";
+
+        //0-待审核,1-待上传,2-审批中,3-审核通过,4-审核不通过,5-预审核,6-预审核拒绝,7-上传成功,8-上传失败
+        List<String> idList = materialInfoService.getDuxiaomanMaterialInfoByStatus(1);
+        if (Check.isNull(idList)) {
+            return;
+        }
+        for (String id : idList) {
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("id", id);
+            HttpUtils2.httpGet(url, requestMap, null);
+            Thread.sleep(2000);
+        }
+    }
+
+    /**
+     * 将7-上传成功状态de素材 进行 素材报备
+     */
+    @XxlJob("materialReportJob")
+    public void materialReport() throws InterruptedException {
+        String url = jobUrl + "/jeecg-boot/duxiaoman/materialInfo/materialReport";
+
+        //0-待审核,1-待上传,2-审批中,3-审核通过,4-审核不通过,5-预审核,6-预审核拒绝,7-上传成功,8-上传失败
+        List<String> idList = materialInfoService.getDuxiaomanMaterialInfoByStatus(7);
+        if (Check.isNull(idList)) {
+            return;
+        }
+        for (String id : idList) {
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("id", id);
+            HttpUtils2.httpGet(url, requestMap, null);
+            Thread.sleep(2000);
+        }
+    }
+
+    /**
+     * 将2-审批中状态的素材 进行 更新报备状态
+     */
+    @XxlJob("materialDetailJob")
+    public void materialDetail() throws InterruptedException {
+        String url = jobUrl + "/jeecg-boot/duxiaoman/materialInfo/materialDetail";
+
+        //0-待审核,1-待上传,2-审批中,3-审核通过,4-审核不通过,5-预审核,6-预审核拒绝,7-上传成功,8-上传失败
+        List<String> idList = materialInfoService.getDuxiaomanMaterialInfoByStatus(2);
+        List<String> idList2 = materialInfoService.getDuxiaomanMaterialInfoByTime();
+        idList.addAll(idList2);
+        if (Check.isNull(idList)) {
+            return;
+        }
+        for (String id : idList) {
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("id", id);
+            HttpUtils2.httpGet(url, requestMap, null);
+            Thread.sleep(2000);
+        }
+    }
+}

+ 35 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/ExternalMaterialCollectionJob.java

@@ -0,0 +1,35 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.utils.HttpUtils2;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * 清洗外部素材集信息表
+ */
+@Component
+@Slf4j
+public class ExternalMaterialCollectionJob {
+
+    @Value("${xxl-job.requestUrl}")
+    private String jobUrl;
+
+    /**
+     * 快手自动创建组
+     */
+    @XxlJob("externalMaterialCollectionJob")
+    public void execute() {
+        String url = jobUrl + "/jeecg-boot/external/materialCollection/createInternalMaterial";
+        log.info("请求地址:{}", url);
+        try {
+            HttpUtils2.httpGet(url, null, null);
+        } catch (Exception e) {
+            XxlJobHelper.log(e.getMessage());
+        }
+    }
+}

+ 25 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouRefreshLiveTokenJob.java

@@ -0,0 +1,25 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.service.IRefreshTokenService;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class KuaiShouRefreshLiveTokenJob {
+    @Autowired
+    private IRefreshTokenService refreshTokenService;
+
+    /**
+     * 刷新快手直播token(ruixuan)
+     *
+     * @throws JobExecutionException
+     */
+    @XxlJob("kuaiShouLiveRefreshTokenJob")
+    public void execute() throws Exception {
+        refreshTokenService.getLiveKuaiShouAgentRefresh();
+    }
+
+}
+

+ 3 - 2
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaiShouYesterdayAgentReportJob.java

@@ -20,8 +20,9 @@ public class KuaiShouYesterdayAgentReportJob {
     @XxlJob("kuaiShouYesterdayAgentReportJob")
     public void execute() throws Exception {
         String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
-        String yesterday = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
-        kuaiShouDailyAgentService.getAgentReportByPage(yesterday, yesterday);
+        String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -2);
+        kuaiShouDailyAgentService.getAgentReportByPage(startDate, endDate);
     }
 }
 

+ 60 - 142
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoCreativeJob.java

@@ -1,28 +1,15 @@
-/*
 package cn.com.ctop.job.kuaishou.handler;
 
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.HttpUtils2;
-import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
+import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
-import com.alibaba.fastjson.JSONObject;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
-import java.text.ParseException;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
-*/
-/**
- * @author syh
- * 自动投放定时任务
- *//*
 
 @Component
 @Slf4j
@@ -34,151 +21,82 @@ public class KuaishouAccountAutoCreativeJob {
     @Autowired
     private IAiKuaishouAdvertiserStrategyService strategyService;
 
-    */
-/**
-     * 自定义上新创意
-     *//*
 
-    @XxlJob("kuaishouCustomCreativeAuto")
-    public void kuaishouCustomCreativeAuto() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 自动投放账户_素材清洗
+     */
+    @XxlJob("kuaishouAccountAutoVideos")
+    public void kuaishouAccountAutoVideos() {
+        List<Long> accountIds = strategyService.getKuaishouAccountAutoStrategy();
+        if (null == accountIds || accountIds.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/customCreativeLimit";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
-                Map<String, Object> requestMap = new HashMap<>();
-                requestMap.put("id", strategy.getId());
-                String result = HttpUtils2.httpGet(url, requestMap, null);
-                JSONObject jsonObject = JSONObject.parseObject(result);
-                if (!Check.isNull(jsonObject)) {
-                    Integer code = jsonObject.getInteger("code");
-                    if (code == 0) {
-                        log.info("快手自动上新异步执行中,accountId:{}", strategy.getAccountId());
-                    } else {
-                        log.error("快手自动上新异执行失败,accountId:{}", strategy.getAccountId());
-                    }
-                } else {
-                    log.error("快手自动上新返回结果为空,accountId:{}", strategy.getAccountId());
-                }
-            }
-        }
-
-
+        log.info("自动投放账户_开始清洗素材");
+        accountIds.forEach(accountId -> {
+            String url = jobUrl + "/jeecg-boot/auto/aiKuaishouAccountAutoVideo/insertAutoVideo?accountId=" + accountId;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 补充创意
-     *//*
+    /**
+     * 创建自定义上新广告创意 、频率 20分钟/次
+     */
 
-    @XxlJob("kuaishouCustomCreativeSupplement")
-    public void kuaishouCustomCreativeSupplement() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    @XxlJob("autoCreateCustomUpNewCreative")
+    public void createCustomUpNewCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        try {
-            String url = jobUrl + "/jeecg-boot/ai/create/kuaishouCustomCreativeSupplement";
-            int hour = DateUtils.getNowHour();
-            for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-                if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 1) {
-                    Map<String, Object> requestMap = new HashMap<>();
-                    requestMap.put("id", strategy.getId());
-                    requestMap.put("hour", hour);
-                    String result = HttpUtils2.httpGet(url, requestMap, null);
-                    JSONObject jsonObject = JSONObject.parseObject(result);
-                    if (!Check.isNull(jsonObject)) {
-                        Integer code = jsonObject.getInteger("code");
-                        if (code == 0) {
-                            log.info("快手创意补充异步执行中,accountId:{}", strategy.getAccountId());
-                        } else {
-                            log.error("快手创意补充异步执行失败,accountId:{}", strategy.getAccountId());
-                        }
-                    } else {
-                        log.error("快手创意补充返回结果为空,accountId:{}", strategy.getAccountId());
-                    }
-                }
-            }
-
-
-        } catch (ParseException e) {
-            e.printStackTrace();
-        }
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createCustomUpNewCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 程序化上新创意
-     *//*
-
-    @XxlJob("kuaishouProgramCreativeAuto")
-    public void kuaishouProgramCreativeAuto() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 创建自定义非上新广告创意 、频率 60分钟/次
+     */
+    @XxlJob("autoCreateCustomCreative")
+    public void createCustomCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/kuaishouProgramCreativeAuto";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
-                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
-                Map<String, Object> requestMap = new HashMap<>();
-                requestMap.put("id", strategy.getId());
-                requestMap.put("videoCnt", videoCnt);
-                String result = HttpUtils2.httpGet(url, requestMap, null);
-                JSONObject jsonObject = JSONObject.parseObject(result);
-                if (!Check.isNull(jsonObject)) {
-                    Integer code = jsonObject.getInteger("code");
-                    if (code == 0) {
-                        log.info("快手上新程序化创意补充异步执行中,accountId:{}", strategy.getAccountId());
-                    } else {
-                        log.error("快手上新程序化异步执行失败,accountId:{}", strategy.getAccountId());
-                    }
-                } else {
-                    log.error("快手上新程序化充返回结果为空,accountId:{}", strategy.getAccountId());
-                }
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createCustomCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
+    }
 
-            }
+    /**
+     * 创建程序化广告创意 频率 60分钟/次
+     */
+    @XxlJob("autoCreateProgramCreative")
+    public void createProgramCreative() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
+            return;
         }
-
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/createProgramCreative?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
 
-    */
-/**
-     * 程序化高质量创意
-     *//*
-
-    @XxlJob("kuaishouProgramCreativeTop")
-    public void kuaishouProgramCreativeTop() {
-        List<AiKuaishouAdvertiserStrategy> strategies = strategyService.getAllEffectStrategy();
-        if (null == strategies || strategies.isEmpty()) {
+    /**
+     * 每日补充创建创意 、频率 每天22点05分钟执行1次
+     */
+    @XxlJob("aotoSupplementCreatives")
+    public void aotoSupplementCreatives() {
+        List<Long> ids = strategyService.getKuaishouAccountAutoStrategyIds();
+        if (null == ids || ids.isEmpty()) {
             return;
         }
-        String url = jobUrl + "/jeecg-boot/ai/create/autoCreateProgramHistoryTopCreative";
-        for (AiKuaishouAdvertiserStrategy strategy : strategies) {
-            if (null != strategy.getOpenProgramCreate() && strategy.getOpenProgramCreate() != 0) {
-                long videoCnt = strategy.getProgramUnitCnt() * 5 / 2;
-                Map<String, Object> requestMap = new HashMap<>();
-                requestMap.put("id", strategy.getId());
-                requestMap.put("videoCnt", videoCnt);
-                String result = HttpUtils2.httpGet(url, requestMap, null);
-                JSONObject jsonObject = JSONObject.parseObject(result);
-                if (!Check.isNull(jsonObject)) {
-                    Integer code = jsonObject.getInteger("code");
-                    if (code == 0) {
-                        log.info("快手历史高质量程序化创意补充异步执行中,accountId:{}", strategy.getAccountId());
-                    } else {
-                        log.error("快手历史高质量程序化异步执行失败,accountId:{}", strategy.getAccountId());
-                    }
-                } else {
-                    log.error("快手历史高质量程序化充返回结果为空,accountId:{}", strategy.getAccountId());
-                }
-            }
-        }
-
+        ids.forEach(id -> {
+            String url = jobUrl + "/jeecg-boot/auto/create/supplementTodayCreatives?id=" + id;
+            HttpUtils.httpGet(url, null, null);
+        });
     }
+
 }
-*/

+ 0 - 45
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouAccountAutoVideoJob.java

@@ -1,45 +0,0 @@
-/*
-package cn.com.ctop.job.kuaishou.handler;
-
-import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.HttpUtils;
-import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouAdvertiserStrategyService;
-import com.xxl.job.core.handler.annotation.XxlJob;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-*/
-/**
- * 自动投放账户_素材
- *//*
-
-@Component
-@Slf4j
-public class KuaishouAccountAutoVideoJob {
-
-    @Value("${xxl-job.requestUrl}")
-    private String jobUrl;
-
-    @Autowired
-    private IAiKuaishouAdvertiserStrategyService strategyService;
-
-    @XxlJob("kuaishouAccountAutoVideo")
-    public void kuaishouCustomCreativeAuto() {
-        List<Long> accountIds = strategyService.getKuaishouAccountAutoStrategy();
-        if (null == accountIds || accountIds.isEmpty()) {
-            return;
-        }
-        accountIds.forEach(accountId -> {
-            String url = jobUrl + "/jeecg-boot/auto/aiKuaishouAccountAutoVideo/insertAutoVideo?accountId=" + accountId;
-            HttpUtils.httpGet(url, null, null);
-        });
-    }
-}
-*/

+ 12 - 15
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouCreateCreativeJob.java

@@ -1,34 +1,39 @@
 package cn.com.ctop.job.kuaishou.handler;
 
-import cn.com.ctop.common.module.entity.CtopOauthToken;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils2;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupTemplate;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupTemplateService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
 @Component
 public class KuaishouCreateCreativeJob {
 
-
     @Autowired
     private IKuaiShouGroupTemplateService groupTemplateService;
     @Autowired
     private ICtopOauthTokenService tokenService;
-    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+
+    @Value("${xxl-job.requestUrl}")
+    private String jobUrl;
 
     /**
      * 组创建成功-创意待创建
      */
     @XxlJob("kuaihouCreateCreative")
     public void execute() {
+        String url = jobUrl + "/jeecg-boot/batch/kuaiShouGroupTemplate/createUnitAgain";
         QueryWrapper<KuaiShouGroupTemplate> templateQueryWrapper = new QueryWrapper<>();
         templateQueryWrapper.eq("task_status", 2);
         templateQueryWrapper.eq("creative_status", 0);
@@ -39,18 +44,10 @@ public class KuaishouCreateCreativeJob {
             return;
         }
         for (KuaiShouGroupTemplate template : list) {
-            executorService.submit(new Runnable() {
-                @Override
-                public void run() {
-                    CtopOauthToken token = tokenService.getTokenByAccountId(template.getAccountId());
-                    if (Check.isNull(token)) {
-                        return;
-                    }
-                    groupTemplateService.createCreative(token.getAccessToken(), template.getUnitId(), template);
-                }
-            });
-
-
+            Map<String, Object> requestMap = new HashMap<>();
+            requestMap.put("id", template.getId());
+            HttpUtils2.httpGet(url, requestMap, null);
         }
     }
+
 }

+ 142 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/KuaishouOrderLIstGetJob.java

@@ -0,0 +1,142 @@
+package cn.com.ctop.job.kuaishou.handler;
+
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.Enums.KuaishouHourEnum;
+import cn.com.ctop.kuaishou.modules.batch.Enums.KuaishouMinSecEnum;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouSupplyChainService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+@Slf4j
+@Component
+public class KuaishouOrderLIstGetJob {
+
+    @Autowired
+    private IKuaishouSupplyChainService ikuaishouSupplyChainService;
+
+    /**
+     * 昨日快分销数据获取
+     **/
+    @XxlJob("yesterdayOrderGet")
+    public void yesterdayOrderGet() throws Exception {
+        log.info("-------------------------获取快分销订单昨日数据开始数据开始--------------------------");
+        String cookie = ikuaishouSupplyChainService.getCookie();
+        if (Check.isNull(cookie)) {
+            log.error("cookie数据为空");
+            return;
+        }
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        String date = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        JSONArray hourList = KuaishouHourEnum.getHourList();
+        JSONArray minSecList = KuaishouMinSecEnum.getMinSecList();
+        for (int i = 0; i < hourList.size(); i++) {
+            String hour = hourList.getString(i);
+            for (int j = 0; j < minSecList.size(); j++) {
+                JSONObject minSecJson = minSecList.getJSONObject(j);
+                String startTime = minSecJson.getString("startTime");
+                String endTime = minSecJson.getString("endTime");
+                String start = date + hour + startTime;
+                String end = date + hour + endTime;
+                System.err.println("开始时间:" + start);
+                System.err.println("结束时间:" + end);
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                Long orderCreateTimeStart = sdf.parse(start).getTime();
+                Long orderCreateTimeEnd = sdf.parse(end).getTime();
+                ikuaishouSupplyChainService.getOrderList(cookie, 0, orderCreateTimeStart, orderCreateTimeEnd);
+
+            }
+        }
+    }
+
+
+    /**
+     * 当前小时数据获取
+     **/
+    @XxlJob("nowHourOrderGet")
+    public void nowHourOrderGet() throws Exception {
+        log.info("-------------------------获取快分销订单当天当小时数据开始--------------------------");
+        String cookie = ikuaishouSupplyChainService.getCookie();
+        if (Check.isNull(cookie)) {
+            log.error("cookie数据为空");
+            return;
+        }
+        String date = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer nowHour = DateUtils.getNowHour();
+        JSONArray minSecList = KuaishouMinSecEnum.getMinSecList();
+        for (int j = 0; j < minSecList.size(); j++) {
+            JSONObject minSecJson = minSecList.getJSONObject(j);
+            String startTime = minSecJson.getString("startTime");
+            String endTime = minSecJson.getString("endTime");
+            String start = date + " " + nowHour + ":" + startTime;
+            String end = date + " " + nowHour + ":" + endTime;
+            System.err.println("开始时间:" + start);
+            System.err.println("结束时间:" + end);
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Long orderCreateTimeStart = sdf.parse(start).getTime();
+            Long orderCreateTimeEnd = sdf.parse(end).getTime();
+            ikuaishouSupplyChainService.getOrderList(cookie, 0, orderCreateTimeStart, orderCreateTimeEnd);
+        }
+    }
+
+
+    /**
+     * 当天数据获取
+     **/
+    @XxlJob("frontHourOrderGet")
+    public void frontHourOrderGet() throws Exception {
+        log.info("-------------------------获取快分销订单当天数据开始--------------------------");
+        String cookie = ikuaishouSupplyChainService.getCookie();
+        if (Check.isNull(cookie)) {
+            log.error("cookie数据为空");
+            return;
+        }
+        String date = DateUtils.getNowDate("yyyy-MM-dd");
+        JSONArray hourList = KuaishouHourEnum.getHourList();
+        JSONArray minSecList = KuaishouMinSecEnum.getMinSecList();
+        for (int i = 0; i < hourList.size(); i++) {
+            String hour = hourList.getString(i);
+            for (int j = 0; j < minSecList.size(); j++) {
+                JSONObject minSecJson = minSecList.getJSONObject(j);
+                String startTime = minSecJson.getString("startTime");
+                String endTime = minSecJson.getString("endTime");
+                String start = date + " " + hour + ":" + startTime;
+                String end = date + " " + hour + ":" + endTime;
+                System.err.println("开始时间:" + start);
+                System.err.println("结束时间:" + end);
+                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                Long orderCreateTimeStart = sdf.parse(start).getTime();
+                Long orderCreateTimeEnd = sdf.parse(end).getTime();
+                ikuaishouSupplyChainService.getOrderList(cookie, 0, orderCreateTimeStart, orderCreateTimeEnd);
+            }
+        }
+
+
+    }
+
+
+    public static void main(String[] args) throws ParseException {
+        String date = DateUtils.getNowDate("yyyy-MM-dd");
+        Integer nowHour = 0;
+        Integer hour = null;
+        if (nowHour == 0) {
+            date = DateUtils.getAnotherDay("yyyy-MM-dd", date, -1);
+            hour = 23;
+        } else {
+            hour = nowHour - 1;
+        }
+
+        System.err.println(date);
+        System.err.println(hour);
+
+
+    }
+}

+ 28 - 0
module-job-kuaishou/src/main/java/cn/com/ctop/job/kuaishou/handler/SynchronousAccountTransactionJob.java

@@ -4,12 +4,14 @@ import cn.com.ctop.kuaishou.modules.report.service.NewMonitorService;
 import cn.com.ctop.toutiao.modules.agent.service.AgentManagementService;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
 
 @Component
 @Slf4j
@@ -42,4 +44,30 @@ public class SynchronousAccountTransactionJob {
         }
 
     }
+
+    /**
+     * 同步头条账户交易流水
+     * 获取前3天数据
+     */
+    @XxlJob("synchronousAccountTransactionNew")
+    public void synchronousAccountTransactionNew() throws Exception {
+
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+
+        String yesterda1 = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1);
+        String yesterda2 = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -2);
+        String yesterda3 = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -3);
+
+        try {
+            agentManagementService.synchronousAccount();
+
+            agentManagementService.synchronousAccountTransactionDayNew(yesterda1,yesterda1,1,1000);
+            agentManagementService.synchronousAccountTransactionDayNew(yesterda2,yesterda2,1,1000);
+            agentManagementService.synchronousAccountTransactionDayNew(yesterda3,yesterda3,1,1000);
+
+        } catch (Exception e) {
+            log.info("同步完成");
+        }
+
+    }
 }

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/AiKuaishouAdvertiserStrategyMapper.java

@@ -14,4 +14,6 @@ import java.util.List;
 public interface AiKuaishouAdvertiserStrategyMapper extends BaseMapper<AiKuaishouAdvertiserStrategy> {
 
     List<Long> getKuaishouAccountAutoStrategy();
+
+    List<Long> getKuaishouAccountAutoStrategyIds();
 }

+ 10 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/mapper/xml/AiKuaishouAdvertiserStrategyMapper.xml

@@ -3,12 +3,16 @@
 <mapper namespace="cn.com.ctop.kuaishou.modules.ai.mapper.AiKuaishouAdvertiserStrategyMapper">
 
     <select id="getKuaishouAccountAutoStrategy" resultType="java.lang.Long">
-        SELECT
-            account_id
-        FROM
-            ctop_ai_kuaishou_account_auto_strategy
-        WHERE
-            status = 1
+        SELECT account_id
+        FROM ctop_ai_kuaishou_account_auto_strategy
+        WHERE status = 1
+        GROUP BY account_id
+    </select>
+
+    <select id="getKuaishouAccountAutoStrategyIds" resultType="java.lang.Long">
+        SELECT id
+        FROM ctop_ai_kuaishou_account_auto_strategy
+        WHERE status = 1
     </select>
 
 </mapper>

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

@@ -28,4 +28,6 @@ public interface IAiKuaishouAdvertiserStrategyService extends IService<AiKuaisho
     List<AiKuaishouAdvertiserStrategy> getAllEffectStrategy();
 
     List<Long> getKuaishouAccountAutoStrategy();
+
+    List<Long> getKuaishouAccountAutoStrategyIds();
 }

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouAdvertiserStrategyServiceImpl.java

@@ -116,6 +116,11 @@ public class AiKuaishouAdvertiserStrategyServiceImpl extends ServiceImpl<AiKuais
         return kuaishouAdvertiserStrategyMapper.getKuaishouAccountAutoStrategy();
     }
 
+    @Override
+    public List<Long> getKuaishouAccountAutoStrategyIds() {
+        return kuaishouAdvertiserStrategyMapper.getKuaishouAccountAutoStrategyIds();
+    }
+
     private Map<String,Object> historicalMissingMaterialCreateCreative(AiKuaishouAdvertiserStrategy strategy) {
         Map<String,Object>result =new HashMap<>();
         //判定是否单一应用

+ 2 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/KuaishouLandpagePackageServiceImpl.java

@@ -128,8 +128,8 @@ public class KuaishouLandpagePackageServiceImpl extends ServiceImpl<KuaishouLand
         landpagePackage.setSiteId(jsonObject.getLong("id"));
         landpagePackage.setUrl(jsonObject.getString("url"));
         landpagePackage.setBizType(jsonObject.getInteger("biz_type"));
-        landpagePackage.setLandpageCreateTime(jsonObject.getSqlDate("create_time"));
-        landpagePackage.setLandpageUpdateTime(jsonObject.getSqlDate("update_time"));
+      /*  landpagePackage.setLandpageCreateTime(jsonObject.getSqlDate("create_time"));
+        landpagePackage.setLandpageUpdateTime(jsonObject.getSqlDate("update_time"));*/
         JSONArray compsArr = jsonObject.getJSONArray("comps");
         if (!Check.isNull(compsArr)) {
             landpagePackage.setComps(JSONObject.toJSONString(compsArr));

+ 72 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/Enums/KuaishouHourEnum.java

@@ -0,0 +1,72 @@
+package cn.com.ctop.kuaishou.modules.batch.Enums;
+
+
+import com.alibaba.fastjson.JSONArray;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum KuaishouHourEnum {
+    HOUR_0(" 00:"),
+    HOUR_1(" 01:"),
+    HOUR_2(" 02:"),
+    HOUR_3(" 03:"),
+    HOUR_4(" 04:"),
+    HOUR_5(" 05:"),
+    HOUR_6(" 06:"),
+    HOUR_7(" 07:"),
+    HOUR_8(" 08:"),
+    HOUR_9(" 09:"),
+    HOUR_10(" 10:"),
+    HOUR_11(" 11:"),
+    HOUR_12(" 12:"),
+    HOUR_13(" 13:"),
+    HOUR_14(" 14:"),
+    HOUR_15(" 15:"),
+    HOUR_16(" 16:"),
+    HOUR_17(" 17:"),
+    HOUR_18(" 18:"),
+    HOUR_19(" 19:"),
+    HOUR_20(" 20:"),
+    HOUR_21(" 21:"),
+    HOUR_22(" 22:"),
+    HOUR_23(" 23:");
+
+
+    /**
+     * 类型
+     */
+    private String value;
+
+
+    KuaishouHourEnum(String value) {
+        this.value = value;
+
+    }
+
+    public static JSONArray getHourList() {
+        JSONArray hourList = new JSONArray();
+        for (KuaishouHourEnum hourEnum : KuaishouHourEnum.values()) {
+            hourList.add(hourEnum.getValue());
+        }
+        return hourList;
+    }
+
+
+    public String getValue() {
+        return this.value;
+    }
+
+
+    public void setType(String value) {
+        this.value = value;
+    }
+
+    public static void main(String[] args) {
+        JSONArray hourList = getHourList();
+        System.err.println(hourList);
+    }
+
+
+
+}

+ 63 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/Enums/KuaishouMinSecEnum.java

@@ -0,0 +1,63 @@
+package cn.com.ctop.kuaishou.modules.batch.Enums;
+
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum KuaishouMinSecEnum {
+    MIN_SEC_1("00:00", "10:00"),
+    MIN_SEC_2("10:00", "20:00"),
+    MIN_SEC_3("20:00", "30:00"),
+    MIN_SEC_4("30:00", "40:00"),
+    MIN_SEC_5("40:00", "50:00"),
+    MIN_SEC_6("50:00", "60:00");
+
+
+    /**
+     * 类型
+     */
+    private String startTime;
+    private String endTime;
+
+
+    KuaishouMinSecEnum(String startTime, String endTime) {
+        this.startTime = startTime;
+        this.endTime = endTime;
+
+    }
+
+    public static JSONArray getMinSecList() {
+        JSONArray minSecList = new JSONArray();
+        for (KuaishouMinSecEnum minSecEnum : KuaishouMinSecEnum.values()) {
+            JSONObject json = new JSONObject();
+            json.put("startTime",minSecEnum.getStartTime());
+            json.put("endTime",minSecEnum.getEndTime());
+            minSecList.add(json);
+        }
+        return minSecList;
+    }
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public static void main(String[] args) {
+        JSONArray minSecList = getMinSecList();
+        System.err.println(minSecList);
+    }
+}

+ 276 - 6
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouRealTimeController.java

@@ -1,19 +1,36 @@
 package cn.com.ctop.kuaishou.modules.batch.controller;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.entity.UserAllocation;
+import cn.com.ctop.common.module.material.entity.MaterialVideoAuthor;
 import cn.com.ctop.common.module.service.ICtopOauthTokenService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouRealTimeDataService;
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportHourlyGroup;
+import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportHourlyGroupService;
+import cn.com.ctop.kuaishou.modules.utils.LinkUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.gson.JsonObject;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
+import org.checkerframework.checker.units.qual.A;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.lang.reflect.Field;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 广告组-app信息
@@ -30,7 +47,24 @@ public class KuaiShouRealTimeController {
     @Autowired
     private ICtopOauthTokenService oauthTokenService;
 
+    @Autowired
+    private ICtopOauthTokenService tokenService;
+
+    @Autowired
+    IKuaishouReportHourlyGroupService kuaishouReportHourlyGroupService;
+
+
+    @Autowired
+    IKuaishouInterfaceService kuaishouInterfaceService;
+
+
 
+
+    /**
+     *  快手- 获取实时数据 计划
+     * @param requestJson
+     * @return
+     */
     @PostMapping(value = "/getCampaignDate")
     public Result<JSONArray> getCampaignDate(@RequestBody JSONObject requestJson) {
         Result<JSONArray> result = new Result<>();
@@ -64,6 +98,13 @@ public class KuaiShouRealTimeController {
     }
 
 
+
+
+    /**
+     *  快手- 获取实时数据 组
+     * @param requestJson
+     * @return
+     */
     @PostMapping(value = "/getUnitDate")
     public Result<JSONArray> getUnitDate(@RequestBody JSONObject requestJson) {
         Result<JSONArray> result = new Result<>();
@@ -77,9 +118,9 @@ public class KuaiShouRealTimeController {
                 throw new Exception("未获取到账户信息");
             }
             Long unitId = requestJson.getLong("unitId");
-            if (Check.isNull(unitId)) {
+            /*if (Check.isNull(unitId)) {
                 throw new Exception("请传入组id");
-            }
+            }*/
             String startDate = requestJson.getString("startDate");
             String endDate = requestJson.getString("endDate");
             if (Check.isNull(startDate) || Check.isNull(endDate)) {
@@ -96,4 +137,233 @@ public class KuaiShouRealTimeController {
         return result;
     }
 
+
+    /**
+     * 盯盘-快手 组实时数据信息
+     * @param accountId
+     * @param pageNum
+     * @param pageSize
+     * @return
+     */
+    @GetMapping(value = "/getUnitDateInfo")
+    public Result getUnitDate(@RequestParam("accountId") Long accountId,
+                                         @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
+                                         @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize) {
+
+        DecimalFormat df = new DecimalFormat("#.000");
+
+        String nowDate = DateUtils.getNowDate("yyyy-MM-dd");
+        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+
+
+        List<KuaishouReportHourlyGroup> unitList = new ArrayList<>();
+
+
+        //优化目标
+        Integer conver = 0;
+        //获取广告组的出价
+        Map unitPrice = kuaishouInterfaceService.getKuaishouUnitList(token, null,new Date(), new Date() , 1,pageNum,pageSize);
+
+        JSONArray array = JSONArray.parseArray(unitPrice.get("details").toString());
+
+        for (Object obj : array) {
+
+            KuaishouReportHourlyGroup unitInfo = new KuaishouReportHourlyGroup();
+            //获取组id
+            List<Long> unitIdList = new ArrayList<>();
+            JSONObject vo = JSONObject.parseObject(obj.toString());
+            unitIdList.add(vo.getLong("unit_id"));
+
+            //广告主 当天 实时 组 数据信息
+            JSONArray unitData = realTimeDataService.getUnitDatePage(accountId, unitIdList, token.getAccessToken(), nowDate, nowDate, pageNum, pageSize);
+            List<KuaishouReportHourlyGroup> k = JSONArray.parseArray(unitData.toString(),KuaishouReportHourlyGroup.class);
+            if (!Check.isNull(k)){
+                unitInfo  = k.get(0);
+            }
+
+            unitInfo.setTotalCount(Integer.valueOf(unitPrice.get("totalCount").toString()));
+
+
+
+            unitInfo.setUnitName(vo.getString("unit_name"));
+
+            //出价
+            unitInfo.setBid(vo.getLong("bid"));
+            unitInfo.setCpaBid(vo.getLong("cpa_bid"));
+            unitInfo.setBidType(vo.getInteger("bid_type"));
+            //优化目标
+            conver = vo.getInteger("ocpx_action_type");
+            unitInfo.setConverType(conver);
+            //计划id
+            unitInfo.setCampaignId(vo.getLong("campaign_id"));
+            //组id
+            unitInfo.setUnitId(vo.getLong("unit_id"));
+            unitInfo.setUnitName(vo.getString("unit_name"));
+
+            //投放状态 1:投放中;2:暂停 3:删除
+            unitInfo.setPutStatus(vo.getInteger("put_status"));
+
+            //激活成本 = 花费  / 激活数
+            String activationCost = "0";
+
+            if (!Check.isNull(k)){
+                if (unitInfo.getCharge().doubleValue() != new Double(0) && unitInfo.getActivation() != 0l) {
+                    Double activation_cost = unitInfo.getCharge().doubleValue() / unitInfo.getActivation();
+                    activationCost = df.format(activation_cost);
+                }
+
+            unitInfo.setActivationCost(activationCost);
+
+
+                //优化目标: 激活,  付费,  行为,  表单提交,  注册,  唤起应用,  关键行为
+                //对应转化数 激活数,付费数,行为数,表单提交数,注册数,唤起应用次数,关键行为数
+                //优化目标id 来源---ctop_kuaishou_ocpx_action_type_config
+                //激活
+                if (conver == 180) {
+                    unitInfo.setConverNum(unitInfo.getActivation().intValue());
+                }
+                //付费
+                if (conver == 190) {
+                    unitInfo.setConverNum(unitInfo.getEventPay().intValue());
+                }
+                //行为
+                if (conver == 2) {
+                    unitInfo.setConverNum(unitInfo.getBclick().intValue());
+                }
+                //表单提交
+                if (conver == 53) {
+                    unitInfo.setConverNum(unitInfo.getFormCount().intValue());
+                }
+                //注册
+                if (conver == 396) {
+                    unitInfo.setConverNum(unitInfo.getEventRegister().intValue());
+                }
+                //唤起应用
+                if (conver == 324) {
+                    unitInfo.setConverNum(unitInfo.getEventAppInvoked().intValue());
+                }
+                //关键行为
+                if (conver == 773) {
+                    unitInfo.setConverNum(unitInfo.getKeyAction().intValue());
+                }
+                //转化成本 = 花费 / 转化数
+                unitInfo.setConverCost(Check.isNull(unitInfo.getCharge()) || Check.isNull(unitInfo.getConverNum()) ? 0 : unitInfo.getCharge().doubleValue() / unitInfo.getConverNum().doubleValue());
+                if (unitInfo.getConverCost().isNaN() || unitInfo.getConverCost().isInfinite()) {
+                    unitInfo.setConverCost(new Double(0));
+                }
+
+                //操作建议
+                //消耗
+                Double charge = unitInfo.getCharge().doubleValue();
+                //出价 单位:厘
+                long bid = new Long("1000");
+                //2:CPC
+                if (unitInfo.getBidType() == 2){
+                    bid = unitInfo.getBid();
+                //10:OCPM
+                }else if(unitInfo.getBidType() == 10){
+                    bid = unitInfo.getCpaBid();
+                }
+                Double price = new Double(bid/1000).doubleValue();
+
+                //转化数量
+                Integer converNum = unitInfo.getConverNum();
+                //转化成本
+                Double converCost = unitInfo.getConverCost();
+
+                //1. 转化成本大于出价×120%,消耗大于500元:
+                if ((converCost > price * 1.2) && (charge > 500)) {
+                    unitInfo.setOperationAgree("高成本 | 有消耗");
+                    unitInfo.setOperationAgreeContent("建议限制预算");
+                    unitInfo.setOperationAgreeInfo("当前广告组转化成本偏高且消耗大于500,建议限制预算;");
+                }
+                //2.  转化成本大于出价×120%,转化数大于10小于等于50:
+                if (converCost > price * 1.2 && LinkUtils.isInTheInterval(String.valueOf(converNum), "(10,50)")) {
+                    unitInfo.setOperationAgree("高成本 | 有转化");
+                    unitInfo.setOperationAgreeContent("建议限制预算");
+                    unitInfo.setOperationAgreeInfo("当前广告组成本大于出价×120%且转化数介于10-50之间;");
+                }
+                //3. 转化成本大于出价×120%,转化数大于50
+                if (converCost > price * 1.2 && LinkUtils.isInTheInterval(String.valueOf(converNum), "(50,∞)")) {
+                    unitInfo.setOperationAgree("高成本 | 有转化");
+                    unitInfo.setOperationAgreeContent("建议降低出价;");
+                    unitInfo.setOperationAgreeInfo("当前转化成本大于出价×120%,转化数大于50,建议降低出价;");
+                }
+                //4.  转化成本小于等于出价×120%,转化数大于10小于等于50
+                if (converCost <= price * 1.2 && LinkUtils.isInTheInterval(String.valueOf(converNum), "(10,50]")) {
+                    unitInfo.setOperationAgree("成本合理 | 有转化");
+                    unitInfo.setOperationAgreeContent("建议复制推广组或放开预算");
+                    unitInfo.setOperationAgreeInfo("当前转化成本小于等于出价×120%,转化数大于10小于等于50,建议复制推广组或放开预算;");
+                }
+                //5.  消耗大于0小于等于100,转化数大于0小于等于10:
+                if (LinkUtils.isInTheInterval(String.valueOf(charge), "(0,100]") && LinkUtils.isInTheInterval(String.valueOf(converNum), "(0,10]")) {
+                    unitInfo.setOperationAgree("消耗少 | 转化少");
+                    unitInfo.setOperationAgreeContent("建议启用加速探索");
+                    unitInfo.setOperationAgreeInfo("当前广告组消耗大于0小于等于100,转化数大于0小于等于10,建议加速探索;");
+                }
+                //6.  消耗大于等于500,转化数等于0:
+                if (charge >= 500 && converNum == 0) {
+                    unitInfo.setOperationAgree("有消耗 | 无转化");
+                    unitInfo.setOperationAgreeContent("建议暂停广告组");
+                    unitInfo.setOperationAgreeInfo("当前广告组消耗大于等于500且转化数等于0,建议暂停推广组;");
+                }
+                //7.   消耗大于100小于等于500
+                if (LinkUtils.isInTheInterval(String.valueOf(charge), "(100,500]")) {
+                    unitInfo.setOperationAgree("有一定消耗");
+                    unitInfo.setOperationAgreeContent("建议继续观察");
+                    unitInfo.setOperationAgreeInfo("当前广告组消耗大于100小于等于500,建议继续观察;");
+                }
+
+
+            }
+            unitInfo.setOperationAgree("暂无");
+            unitInfo.setOperationAgreeContent("暂无");
+            unitInfo.setOperationAgreeInfo("暂无");
+
+
+            setFeidValueNotNull(unitInfo);
+
+            unitList.add(unitInfo);
+
+        }
+        return Result.ok(unitList);
+    }
+
+
+
+
+
+
+
+
+
+    private void setFeidValueNotNull (Object obj){
+        try {
+            for (Field field: obj.getClass().getDeclaredFields()) {
+            field.setAccessible(true);
+            if (field.get(obj) == null){
+                if (field.getGenericType().toString().equals("class java.lang.String")) {
+                    field.set(obj, "0");
+                }else if (field.getGenericType().toString().equals("class java.lang.Integer")) {
+                    field.set(obj, 0);
+                }else if (field.getGenericType().toString().equals("class java.lang.Double")) {
+                    field.set(obj, 0.0);
+                }else if (field.getGenericType().toString().equals("class java.lang.Long")) {
+                    field.set(obj, 0L);
+                }else if(field.getGenericType().toString().equals("class java.math.BigDecimal")){
+                    field.set(obj, new BigDecimal(0));
+                }
+            }
+        }
+
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+
+    }
+
+
+
+
 }

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

@@ -119,6 +119,7 @@ public class KuaiShouGroup {
      * APP图标存储地址
      */
     private String appIconUrl;
+    private Integer unitSource;
 
 
     // 转化目标

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

@@ -0,0 +1,199 @@
+package cn.com.ctop.kuaishou.modules.batch.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 快手电商-供应链订单信息
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2022-12-01
+ */
+@Data
+@TableName("kuaishou_supply_chain")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "kuaishou_supply_chain对象", description = "快手电商-供应链订单信息")
+public class KuaishouSupplyChain {
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
+    private Long id;
+    /**
+     * 订单ID
+     */
+    @Excel(name = "订单ID", width = 15)
+    @ApiModelProperty(value = "订单ID")
+    private Long oid;
+    /**
+     * 商品ID
+     */
+    @Excel(name = "商品ID", width = 15)
+    @ApiModelProperty(value = "商品ID")
+    private Long itemId;
+    /**
+     * 商品标题
+     */
+    @Excel(name = "商品标题", width = 15)
+    @ApiModelProperty(value = "商品标题")
+    private String itemTitle;
+    /**
+     * 商品单价
+     */
+    @Excel(name = "商品单价", width = 15)
+    @ApiModelProperty(value = "商品单价")
+    private Long reservePrice;
+    /**
+     * 商品图片
+     */
+    @Excel(name = "商品图片", width = 15)
+    @ApiModelProperty(value = "商品图片")
+    private String imageUrl;
+    /**
+     * 订单状态
+     */
+    @Excel(name = "订单状态", width = 15)
+    @ApiModelProperty(value = "订单状态")
+    private Integer orderStatus;
+    /**
+     * 订单创建时间
+     */
+    @Excel(name = "订单创建时间", width = 15)
+    @ApiModelProperty(value = "订单创建时间")
+    private Long orderCreateTime;
+    /**
+     * 是否发货
+     */
+    @Excel(name = "是否发货", width = 15)
+    @ApiModelProperty(value = "是否发货")
+    private Integer sendStatus;
+    /**
+     * 订单类型
+     */
+    @Excel(name = "订单类型", width = 15)
+    @ApiModelProperty(value = "订单类型")
+    private Integer settlementBizType;
+    /**
+     * 订单类型翻译
+     */
+    @Excel(name = "订单类型翻译", width = 15)
+    @ApiModelProperty(value = "订单类型翻译")
+    private String settlementBizTypeDesc;
+    /**
+     * 发货时间
+     */
+    @Excel(name = "发货时间", width = 15)
+    @ApiModelProperty(value = "发货时间")
+    private Long sendTime;
+    /**
+     * 收获时间
+     */
+    @Excel(name = "收获时间", width = 15)
+    @ApiModelProperty(value = "收获时间")
+    private Long recvTime;
+    /**
+     * 商家id
+     */
+    @Excel(name = "商家id", width = 15)
+    @ApiModelProperty(value = "商家id")
+    private Long sellerId;
+    /**
+     * 达人id
+     */
+    @Excel(name = "达人id", width = 15)
+    @ApiModelProperty(value = "达人id")
+    private Long promoterId;
+    /**
+     * 达人昵称
+     */
+    @Excel(name = "达人昵称", width = 15)
+    @ApiModelProperty(value = "达人昵称")
+    private String promoterNickName;
+    /**
+     * 活动id
+     */
+    @Excel(name = "活动id", width = 15)
+    @ApiModelProperty(value = "活动id")
+    private Long activityId;
+    /**
+     * 订单金额
+     */
+    @Excel(name = "订单金额", width = 15)
+    @ApiModelProperty(value = "订单金额")
+    private Long orderAmount;
+    /**
+     * 付款金额
+     */
+    @Excel(name = "付款金额", width = 15)
+    @ApiModelProperty(value = "付款金额")
+    private Long payAmount;
+    /**
+     * 服务费率
+     */
+    @Excel(name = "服务费率", width = 15)
+    @ApiModelProperty(value = "服务费率")
+    private Long regimentalPromotionRate;
+    /**
+     * 分成比例
+     */
+    @Excel(name = "分成比例", width = 15)
+    @ApiModelProperty(value = "分成比例")
+    private Long shareRate;
+    /**
+     * 货款基数
+     */
+    @Excel(name = "货款基数", width = 15)
+    @ApiModelProperty(value = "货款基数")
+    private Long baseAmount;
+    /**
+     * 技术服务费
+     */
+    @Excel(name = "技术服务费", width = 15)
+    @ApiModelProperty(value = "技术服务费")
+    private Long serviceAmount;
+    /**
+     * 预估服务费收入
+     */
+    @Excel(name = "预估服务费收入", width = 15)
+    @ApiModelProperty(value = "预估服务费收入")
+    private Long regimentalPromotionAmount;
+    /**
+     * 结算服务费收入
+     */
+    @Excel(name = "结算服务费收入", width = 15)
+    @ApiModelProperty(value = "结算服务费收入")
+    private Long totalRegimentalSettleAmount;
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    @Excel(name = "修改时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+}

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

@@ -0,0 +1,21 @@
+package cn.com.ctop.kuaishou.modules.batch.mapper;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouSupplyChain;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 快手电商-供应链订单信息
+ * @author jeecg-boot
+ * 2022-12-01
+ * @version V1.0
+ */
+public interface KuaishouSupplyChainMapper extends BaseMapper<KuaishouSupplyChain> {
+
+    void replace(@Param(value = "adds") List<KuaishouSupplyChain> supplyChains);
+
+    String getCookie();
+}

+ 4 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouGroupMapper.xml

@@ -38,7 +38,8 @@
         group_update_time,
         create_time,
         update_time,
-        study_status)
+        study_status,
+        unit_source)
         values
         <foreach collection="groups" item="getGroup" separator=",">
             (
@@ -77,7 +78,8 @@
             #{getGroup.groupUpdateTime},
             #{getGroup.createTime},
             #{getGroup.updateTime},
-            #{getGroup.studyStatus})
+            #{getGroup.studyStatus},
+            #{getGroup.unitSource})
         </foreach>
     </insert>
 

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

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouSupplyChainMapper">
+
+    <insert id="replace">
+        replace into ruixuan.kuaishou_supply_chain(
+        id,
+        oid,
+        item_id,
+        item_title,
+        reserve_price,
+        image_url,
+        order_status,
+        order_create_time,
+        send_status,
+        settlement_biz_type,
+        settlement_biz_type_desc,
+        send_time,
+        recv_time,
+        seller_id,
+        promoter_id,
+        promoter_nick_name,
+        activity_id,
+        order_amount,
+        pay_amount,
+        regimental_promotion_rate,
+        share_rate,
+        base_amount,
+        service_amount,
+        regimental_promotion_amount,
+        total_regimental_settle_amount
+        )
+        values
+        <foreach collection="adds" item="add" separator=",">
+            (
+            #{add.id},
+            #{add.oid},
+            #{add.itemId},
+            #{add.itemTitle},
+            #{add.reservePrice},
+            #{add.imageUrl},
+            #{add.orderStatus},
+            #{add.orderCreateTime},
+            #{add.sendStatus},
+            #{add.settlementBizType},
+            #{add.settlementBizTypeDesc},
+            #{add.sendTime},
+            #{add.recvTime},
+            #{add.sellerId},
+            #{add.promoterId},
+            #{add.promoterNickName},
+            #{add.activityId},
+            #{add.orderAmount},
+            #{add.payAmount},
+            #{add.regimentalPromotionRate},
+            #{add.shareRate},
+            #{add.baseAmount},
+            #{add.serviceAmount},
+            #{add.regimentalPromotionAmount},
+            #{add.totalRegimentalSettleAmount}
+            )
+        </foreach>
+    </insert>
+    <select id="getCookie" resultType="java.lang.String">
+        select  cookie  from ruixuan.kuaishou_supply_chain_cookie limit 1
+    </select>
+</mapper>

+ 19 - 11
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/MaterialUploadTaskMapper.xml

@@ -10,17 +10,25 @@
 	</update>
 
     <select id="getMd5List" resultType="java.lang.String">
-    SELECT
-	signature
-	FROM
-	ctop_material_upload_task
-	WHERE
-	task_status = 0
-	GROUP BY
-	signature
-	ORDER BY
-	create_time ASC
-	LIMIT 9
+   select t.signature
+from (select t1.signature
+      from (SELECT signature
+            FROM ctop_material_upload_task
+            WHERE task_status = 0
+              and media_id in (2, 4)
+            group by signature
+            ORDER BY create_time ASC
+            LIMIT 20) t1
+      union all
+      select t2.signature
+      from (SELECT signature
+            FROM ctop_material_upload_task
+            WHERE task_status = 0
+              and media_id in (1, 3)
+            group by signature
+            ORDER BY create_time ASC
+            limit 20) t2) t
+group by t.signature
     </select>
     <select id="getHostingIdList" resultType="java.lang.Long">
 		select  id  from ctop_kuaishou_hosting_task

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

@@ -21,7 +21,7 @@ public interface IKuaishouAccountBudgetService extends IService<KuaishouAccountB
      * @param advertiserId
      * @param accessToken
      */
-    JSONObject getAccountBudget(CtopOauthToken oauthToken);
+    JSONObject getAccountBudget(CtopOauthToken oauthToken) ;
 
     void insertAccountBudget(Long advertiserId, String accessToken);
 

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

@@ -363,6 +363,7 @@ public interface IKuaishouInterfaceService {
      * @param time_filter_type
      */
     JSONArray getGroupList(CtopOauthToken token, Long campaignId, Date startDate, Date endDate, int time_filter_type);
+    Map getKuaishouUnitList(CtopOauthToken token, Long unidId, Date startDate, Date endDate, int time_filter_type,Integer pageNum, Integer pageSize);
 
 
     /**

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

@@ -2,8 +2,13 @@ package cn.com.ctop.kuaishou.modules.batch.service;
 
 import com.alibaba.fastjson.JSONArray;
 
+import java.util.List;
+import java.util.Map;
+
 public interface IKuaishouRealTimeDataService {
     JSONArray getCampaignDate(Long accountId, String token, Long campaignId, String startDate, String endDate);
 
     JSONArray getUnitDate(Long accountId, String token, Long unitId, String startDate, String endDate);
+
+    JSONArray getUnitDatePage(Long accountId, List<Long> campaignIds, String token, String startDate, String endDate, Integer pageNum, Integer pageSize);
 }

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

@@ -0,0 +1,16 @@
+package cn.com.ctop.kuaishou.modules.batch.service;
+
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouSupplyChain;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 快手电商-供应链订单信息
+ * @author jeecg-boot
+ * 2022-12-01
+ * @version V1.0
+ */
+public interface IKuaishouSupplyChainService extends IService<KuaishouSupplyChain> {
+    void getOrderList(String cookie,Integer offset,Long orderCreateTimeStart,Long orderCreateTimeEnd) throws Exception;
+
+    String getCookie();
+}

+ 6 - 55
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/AccountWarningServiceImpl.java

@@ -78,7 +78,6 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
                     }
                 }
             }
-
             if (!Check.isNull(nowCost) && nowCost.compareTo(new BigDecimal(0)) != 0) {
                 BigDecimal yesterdayHourCost = hourlyAccountMapper.getCost(accountId, maxHour, anotherDay);
                 if (!Check.isNull(yesterdayHourCost) && yesterdayHourCost.compareTo(new BigDecimal(0)) != 0) {
@@ -89,15 +88,18 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
                     }
                 }
             }
-
         } catch (Exception e) {
             e.printStackTrace();
         }
 
     }
 
-    private void sendYesterdayMessage(Long accountId, String authName, Integer maxHour, BigDecimal nowCost, Long projectId, String projectName) {
 
+
+
+
+
+    private void sendYesterdayMessage(Long accountId, String authName, Integer maxHour, BigDecimal nowCost, Long projectId, String projectName) {
         StringBuilder text = new StringBuilder();
         text.append("较昨日同时段消耗预警").append("<br/>")
                 .append("您的项目:" + projectName + "下的,").append("<br/>")
@@ -105,39 +107,13 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
                 .append("相较于昨日 " + maxHour + "时").append("<br/>")
                 .append("出现消耗暴涨,").append("消耗金额为:" + nowCost).append("<br/>")
                 .append("请您及时查看!");
-
-
-        QueryWrapper<MailLog> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("account_id", accountId);
-        queryWrapper.eq("hour", maxHour);
-        queryWrapper.eq("mail_type", 3);
-        queryWrapper.orderByDesc("create_time");
-        queryWrapper.last("limit 1");
-        MailLog checkMailLog = mailLogMapper.selectOne(queryWrapper);
-        if (Check.isNull(checkMailLog)) {
-            List<String> mailList = mailLogMapper.selectMailList(projectId);
-            String subject = "快手-较昨日同时段账户消耗预警";
-            try {
-                SendMailUtil.sendMail(mailList, subject, text.toString());
-                MailLog mailLog = new MailLog();
-                mailLog.setAccountId(accountId);
-                mailLog.setMailType(3);
-                mailLog.setHour(maxHour);
-                mailLog.setContent(text.toString());
-                mailLog.setSendEmil(JSON.toJSONString(mailList));
-                mailLog.setSubject(subject);
-                mailLogMapper.insert(mailLog);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
             List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
             corpWexinUtils.sendMessage(wexinIds, text.toString());
-        }
+
     }
 
 
     private void sendMessage(Long accountId, String authName, Integer hour, BigDecimal amount, Long projectId, String projectName) {
-
         StringBuilder text = new StringBuilder();
         text.append("较上时段消耗预警").append("<br/>")
                 .append("您的项目:" + projectName + " 下的").append("<br/>")
@@ -145,31 +121,6 @@ public class AccountWarningServiceImpl implements IAccountWarningService {
                 .append(hour + " 时").append("相较于 " + (hour - 1) + " 时").append("<br/>")
                 .append("出现消耗暴涨,").append("消耗金额为:" + amount).append("<br/>")
                 .append("请您及时查看!");
-
-        QueryWrapper<MailLog> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("account_id", accountId);
-        queryWrapper.eq("hour", hour);
-        queryWrapper.eq("mail_type", 2);
-        queryWrapper.orderByDesc("create_time");
-        queryWrapper.last("limit 1");
-        MailLog checkMailLog = mailLogMapper.selectOne(queryWrapper);
-        if (Check.isNull(checkMailLog)) {
-            List<String> mailList = mailLogMapper.selectMailList(projectId);
-            String subject = "快手-账户消耗预警";
-            try {
-                SendMailUtil.sendMail(mailList, subject, text.toString());
-                MailLog mailLog = new MailLog();
-                mailLog.setAccountId(accountId);
-                mailLog.setMailType(2);
-                mailLog.setHour(hour);
-                mailLog.setContent(text.toString());
-                mailLog.setSendEmil(JSON.toJSONString(mailList));
-                mailLog.setSubject(subject);
-                mailLogMapper.insert(mailLog);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
         List<JSONObject> wexinIds = mailLogMapper.selectWeiXinIdList(projectId);
         corpWexinUtils.sendMessage(wexinIds, text.toString());
 

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

@@ -146,6 +146,11 @@ public class IKuaiShouCommentServiceImpl implements IKuaiShouCommentService {
         params.put("advertiser_id", accountId);
         params.put("shield_list", comments);
         String result = HttpUtils.httpPostRequest(url, params, header);
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         JSONObject resultJson = JSONObject.parseObject(result);
         if (!Check.isNull(resultJson)) {
             Integer code = resultJson.getInteger("code");

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

@@ -101,6 +101,7 @@ public class KuaiShouHistoryReportTaskServiceImpl extends ServiceImpl<KuaiShouHi
                     param.put("task_params", taskParams);
 
                     String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+                    Thread.sleep(500);
                     JSONObject resultJson = JSONObject.parseObject(result);
                     if (!Check.isNull(resultJson)) {
                         Integer code = resultJson.getInteger("code");

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

@@ -66,6 +66,11 @@ public class KuaiShouReportDailyMaterialServiceImpl extends ServiceImpl<KuaiShou
         param.put("page_size", 2000);
         param.put("page", page);
         String result = HttpUtils.httpPostRequest(url, param, headers);
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         JSONObject resultJson = JSONObject.parseObject(result);
         if (Check.isNull(resultJson)) {
             return;

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

@@ -86,7 +86,7 @@ public class KuaishouAccountBudgetServiceImpl extends ServiceImpl<KuaishouAccoun
     }
 
     @Override
-    public JSONObject getAccountBudget(CtopOauthToken oauthToken) {
+    public JSONObject getAccountBudget(CtopOauthToken oauthToken)  {
         String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ACCOUNT_BUDGET;
         Map<String, String> headers = new HashMap<>();
         headers.put("Access-Token", oauthToken.getAccessToken());
@@ -94,6 +94,11 @@ public class KuaishouAccountBudgetServiceImpl extends ServiceImpl<KuaishouAccoun
         JSONObject json = new JSONObject();
         json.put("advertiser_id", oauthToken.getAccountId());
         String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         JSONObject resultJson = JSONObject.parseObject(result);
         if (!Check.isNull(resultJson)) {
             Integer code = resultJson.getInteger("code");

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

@@ -7,10 +7,11 @@ import cn.com.ctop.common.module.utils.PropertiesUtils;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouRealTimeDataService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.google.gson.JsonArray;
+import com.rabbitmq.client.LongString;
 import org.springframework.stereotype.Service;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
 
 @Service
 public class KuaishouRealTimeDataServiceImpl implements IKuaishouRealTimeDataService {
@@ -86,9 +87,50 @@ public class KuaishouRealTimeDataServiceImpl implements IKuaishouRealTimeDataSer
         param.put("page_size", 2000);
         param.put("page", 1);
 
-        JSONArray array = new JSONArray();
-        array.add(unitId);
-        param.put("unit_ids", array);
+        if (!Check.isNull(unitId)){
+            JSONArray array = new JSONArray();
+            array.add(unitId);
+            param.put("unit_ids", array);
+        }
+
+        try {
+            String result = HttpUtils.httpPostRequest(url, param, headers);
+            JSONObject jsonObject = JSONObject.parseObject(result);
+            if (!Check.isNull(jsonObject)) {
+                Integer code = jsonObject.getInteger("code");
+                if (code == 0) {
+                    JSONObject data = jsonObject.getJSONObject("data");
+                    if (!Check.isNull(data)) {
+                        return data.getJSONArray("details");
+                    }
+                }
+            }
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+
+    @Override
+    public JSONArray getUnitDatePage(Long accountId, List<Long> unitIdList ,String token, String startDate, String endDate, Integer pageNum, Integer pageSize) {
+        Map map = new HashMap();
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token);
+        Map<String, Object> param = new HashMap<>();
+        param.put("start_date", startDate);
+        param.put("end_date", endDate);
+        param.put("advertiser_id", accountId);
+        param.put("temporal_granularity", "DAILY");
+        param.put("page_size", pageSize);
+        param.put("page", pageNum);
+
+        param.put("unit_ids",unitIdList);
+
         try {
             String result = HttpUtils.httpPostRequest(url, param, headers);
             JSONObject jsonObject = JSONObject.parseObject(result);
@@ -97,6 +139,8 @@ public class KuaishouRealTimeDataServiceImpl implements IKuaishouRealTimeDataSer
                 if (code == 0) {
                     JSONObject data = jsonObject.getJSONObject("data");
                     if (!Check.isNull(data)) {
+                        //map.put("totalCount",data.getInteger("total_count"));
+                        //map.put("details",data.getJSONArray("details"));
                         return data.getJSONArray("details");
                     }
                 }

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

@@ -0,0 +1,134 @@
+package cn.com.ctop.kuaishou.modules.batch.service.impl;
+
+
+import cn.com.ctop.common.module.service.ISendMessageService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.HttpUtils;
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaishouSupplyChain;
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaishouSupplyChainMapper;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouSupplyChainService;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 快手电商-供应链订单信息
+ *
+ * @author jeecg-boot
+ * 2022-12-01
+ * @version V1.0
+ */
+@Slf4j
+@Service
+public class KuaishouSupplyChainServiceImpl extends ServiceImpl<KuaishouSupplyChainMapper, KuaishouSupplyChain> implements IKuaishouSupplyChainService {
+    private static String url = "https://cps.kwaixiaodian.com/distribute/pc/investment/order/list";
+    @Autowired
+    private ISendMessageService sendMessageService;
+    @Autowired
+    private KuaishouSupplyChainMapper supplyChainMapper;
+
+    @Override
+    public void getOrderList(String cookie, Integer offset, Long orderCreateTimeStart, Long orderCreateTimeEnd) throws Exception {
+        Map<String, Object> params = new HashMap<>();
+        if (!Check.isNull(orderCreateTimeStart)) {
+            params.put("orderCreateTimeStart", orderCreateTimeStart);
+        }
+        if (!Check.isNull(orderCreateTimeEnd)) {
+            params.put("orderCreateTimeEnd", orderCreateTimeEnd);
+        }
+        params.put("fundType", 1);
+        params.put("limit", 2000);
+        params.put("offset", offset);
+
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Cookie", cookie);
+
+        String resultStr = HttpUtils.KuaiShouttpGetRequest(url, params, headers);
+        JSONObject result = JSONObject.parseObject(resultStr);
+        if (Check.isNull(result)) {
+            log.error("快分销数据返回为空");
+            return;
+        }
+        Integer code = result.getInteger("result");
+        if (code != 1) {
+            log.info("快分销数据返回异常:", resultStr);
+            sendMessageService.sendMessage("113dee46c7df464da78c07a985e92cd1", "快手供应链cookie失效,请及时更新。媒体返回信息:" + resultStr);
+            return;
+        }
+        JSONObject dataJson = result.getJSONObject("data");
+        if (Check.isNull(dataJson)) {
+            log.error("快分销数据返回为data数据为空");
+            return;
+        }
+        JSONArray list = dataJson.getJSONArray("list");
+        if (Check.isNull(list)) {
+            log.error("快分销数据返回为list数据为空");
+            return;
+        }
+        log.info("快分销当前数据条数:{}", list.size());
+        List<KuaishouSupplyChain> supplyChains = new ArrayList<>();
+        for (int i = 0; i < list.size(); i++) {
+            JSONObject jsonObject = list.getJSONObject(i);
+            KuaishouSupplyChain supplyChain = new KuaishouSupplyChain();
+            supplyChain.setOid(jsonObject.getLong("oid"));
+            JSONObject item = jsonObject.getJSONArray("itemList").getJSONObject(0);
+            if (!Check.isNull(item)) {
+                supplyChain.setItemId(item.getLong("itemId"));
+                supplyChain.setItemTitle(item.getString("itemTitle"));
+                supplyChain.setReservePrice(item.getLong("reservePrice"));
+                supplyChain.setImageUrl(item.getString("imageUrl"));
+            }
+            supplyChain.setOrderStatus(jsonObject.getInteger("orderStatus"));
+            supplyChain.setOrderCreateTime(jsonObject.getLong("orderCreateTime"));
+            supplyChain.setSendStatus(jsonObject.getInteger("sendStatus"));
+            supplyChain.setSettlementBizType(jsonObject.getInteger("settlementBizType"));
+            supplyChain.setSettlementBizTypeDesc(jsonObject.getString("settlementBizTypeDesc"));
+            supplyChain.setSendTime(jsonObject.getLong("sendTime"));
+            supplyChain.setRecvTime(jsonObject.getLong("recvTime"));
+            supplyChain.setSellerId(jsonObject.getLong("sellerId"));
+            supplyChain.setPromoterId(jsonObject.getLong("promoterId"));
+            supplyChain.setPromoterNickName(filterSupplement(jsonObject.getString("promoterNickName")));
+            supplyChain.setActivityId(jsonObject.getLong("activityId"));
+            supplyChain.setOrderAmount(jsonObject.getLong("orderAmount"));
+            supplyChain.setPayAmount(jsonObject.getLong("payAmount"));
+            supplyChain.setRegimentalPromotionRate(jsonObject.getLong("regimentalPromotionRate"));
+            supplyChain.setShareRate(jsonObject.getLong("shareRate"));
+            supplyChain.setBaseAmount(jsonObject.getLong("baseAmount"));
+            supplyChain.setServiceAmount(jsonObject.getLong("serviceAmount"));
+            supplyChain.setRegimentalPromotionAmount(jsonObject.getLong("regimentalPromotionAmount"));
+            supplyChain.setTotalRegimentalSettleAmount(jsonObject.getLong("totalRegimentalSettleAmount"));
+            supplyChains.add(supplyChain);
+        }
+        supplyChainMapper.replace(supplyChains);
+        Thread.sleep(2000L);
+        getOrderList(cookie, offset + 2000, orderCreateTimeStart, orderCreateTimeEnd);
+    }
+
+    @Override
+    public String getCookie() {
+        return supplyChainMapper.getCookie();
+    }
+
+    public static String filterSupplement(String content) {
+        StringBuilder sb = new StringBuilder();
+        for (char ch : content.toCharArray()) {
+            if (!Character.isHighSurrogate(ch) && !Character.isLowSurrogate(ch)) {
+                sb.append(ch);
+            }
+        }
+        return sb.toString();
+    }
+
+}
+
+
+

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

@@ -127,4 +127,36 @@ public class KuaishouReportHourlyGroup implements Serializable {
     private Date createTime;
     @JsonProperty
     private Date updateTime;
+
+    @JsonProperty
+    private Long eventAppInvoked;
+
+    @JsonProperty
+    private Long keyAction;
+
+    @JsonProperty
+    private Integer totalCount;
+
+
+    @JsonProperty
+    private Integer putStatus; //1:投放中;2:暂停 3:删除
+
+    //出价
+    private Long bid;
+    private Long cpaBid;
+    //出价类型 1:CPM,2:CPC,6:OCPC(使用 OCPC 代表 OCPX),10:OCPM,20:eCPC
+    private Integer bidType;
+    //转化类型
+    private Integer converType;
+    //转化数
+    private Integer converNum;
+    //转化成本
+    private Double converCost;
+    //激活成本
+    private String activationCost;
+    //操作建议
+    private String operationAgree;
+    private String operationAgreeContent;
+    private String operationAgreeInfo;
+
 }

module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouCostGroupMapper.xml → module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouSupplyChainMapper.xml


+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/EtlKuaiShouGroupDailyReportServiceImpl.java

@@ -58,6 +58,11 @@ public class EtlKuaiShouGroupDailyReportServiceImpl extends ServiceImpl<EtlKuaiS
         param.put("page_size", 2000);
         param.put("page", page);
         String result = HttpUtils.httpPostRequest(url, param, headers);
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         JSONObject resultJson = JSONObject.parseObject(result);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");

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

@@ -11,7 +11,6 @@ import cn.com.ctop.kuaishou.modules.report.mapper.KuaiShouDailyAgentMapper;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouDailyAgentService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,13 +39,14 @@ public class KuaiShouDailyAgentServiceImpl extends ServiceImpl<KuaiShouDailyAgen
 
     @Override
     public void getAgentReportByPage(String startDate, String endDate) {
-        QueryWrapper<OauthAgentToken> agentTokenQueryWrapper = new QueryWrapper<>();
-        agentTokenQueryWrapper.eq("media_id", 2);
-        List<OauthAgentToken> list = agentTokenService.list(agentTokenQueryWrapper);
-        if (!Check.isNull(list)) {
-            for (OauthAgentToken agentToken : list) {
-                getAgentReport(agentToken.getAccessToken(), agentToken.getAgentId(), startDate, endDate, 1);
-            }
+        List<Long> appList = new ArrayList<>();
+        appList.add(27L);
+        appList.add(165893351L);
+        for (int i = 0; i < appList.size(); i++) {
+            Long appId = appList.get(i);
+            log.info("获取代理商数据AppId:{}",appId);
+            OauthAgentToken agentToken = agentTokenService.getTokenByAppId(appId);
+            getAgentReport(agentToken.getAccessToken(), agentToken.getAgentId(), startDate, endDate, 1);
         }
     }
 

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

@@ -124,6 +124,7 @@ public class KuaishouAudienceReportDailyServiceImpl extends ServiceImpl<Kuaishou
                 requestJson.put("unit_ids", units);
             }
             String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
+            Thread.sleep(500);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");

+ 2 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouGroupExploreServiceImpl.java

@@ -71,6 +71,7 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
             params.put("advertiser_id", accountId);
             params.put("unit_id", unitId);
             String result = HttpUtils.httpPostRequest(url, params, header);
+            Thread.sleep(500);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
@@ -201,6 +202,7 @@ public class KuaishouGroupExploreServiceImpl extends ServiceImpl<KuaishouGroupEx
             params.put("advertiser_id", accountId);
             params.put("unit_id", unitId);
             String result = HttpUtils.httpPostRequest(url, params, header);
+            Thread.sleep(500);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyGroupServiceImpl.java

@@ -55,6 +55,11 @@ public class KuaishouReportDailyGroupServiceImpl extends ServiceImpl<KuaishouRep
         param.put("page_size", 2000);
         param.put("page", page);
         String result = HttpUtils.httpPostRequest(url, param, headers);
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         JSONObject resultJson = JSONObject.parseObject(result);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportDailyImageServiceImpl.java

@@ -51,6 +51,11 @@ public class KuaishouReportDailyImageServiceImpl extends ServiceImpl<KuaishouRep
         param.put("page", page);
 
         JSONObject resultJson = JSONObject.parseObject(HttpUtils.kuaiShouhttpPostRequest("https://ad.e.kuaishou.com/rest/openapi/v1/report/material_report", param.toJSONString(), headers));
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         if (Check.isNull(resultJson)) {
             log.error("获取素材图片报表返回结果为空,advertiserId:{}", accountId);
             return;

+ 5 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouReportHourlyGroupServiceImpl.java

@@ -42,6 +42,11 @@ public class KuaishouReportHourlyGroupServiceImpl extends ServiceImpl<KuaishouRe
         param.put("page", page);
 
         String result = HttpUtils.httpPostRequest(url, param, headers);
+        try {
+            Thread.sleep(500);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
         JSONObject resultJson = JSONObject.parseObject(result);
         Integer code = resultJson.getInteger("code");
         String message = resultJson.getString("message");

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

@@ -270,8 +270,13 @@ public class RuleKuaiShouPlanServiceImpl extends ServiceImpl<RuleDatePlanKuaisho
                 Integer network = unitTarget.getInteger("network");
                 target.setNetwork(network == null ? 0 : network);
 
-                Integer isOpen = unitDetail.getJSONObject("target").getJSONObject("intelli_extend").getInteger("is_open");
-                target.setIsOpen(isOpen == null ? 0 : isOpen);
+                JSONObject intelliExtend = unitDetail.getJSONObject("target").getJSONObject("intelli_extend");
+                Integer isOpen = 0;
+                if(!Check.isNull(intelliExtend)){
+                    isOpen = intelliExtend.getInteger("is_open");
+                }
+
+                target.setIsOpen(isOpen);
 
                 target.setDeepConversionBid(new BigDecimal(unitDetail.getLong("deep_conversion_bid")).divide(new BigDecimal("1000")));
                 target.setDeepConversionType(unitDetail.getInteger("deep_conversion_type"));

+ 120 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/utils/LinkUtils.java

@@ -2,6 +2,8 @@ package cn.com.ctop.kuaishou.modules.utils;
 
 import com.alibaba.fastjson.JSONObject;
 
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.ArrayList;
@@ -46,4 +48,122 @@ public class LinkUtils {
         return link;
     }
 
+
+
+    /**
+     * 判断data_value是否在interval区间范围内
+     * @param data_value 数值类型的
+     * @param interval 正常的数学区间,包括无穷大等,如:(1,3)、>5%、(-∞,6]、(125%,135%)U(70%,80%)
+     * @return true:表示data_value在区间interval范围内,false:表示data_value不在区间interval范围内
+     */
+    public static boolean isInTheInterval(String data_value,String interval) {
+        //将区间和data_value转化为可计算的表达式
+        String formula = getFormulaByAllInterval(data_value,interval,"||");
+        ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");
+        try {
+            //计算表达式
+            return (Boolean) jse.eval(formula);
+        } catch (Exception t) {
+            return false;
+        }
+    }
+
+
+
+    /**
+     * 将所有阀值区间转化为公式:如
+     * [75,80) =》 date_value < 80 && date_value >= 75
+     * (125%,135%)U(70%,80%) =》 (date_value < 1.35 && date_value > 1.25) || (date_value < 0.8 && date_value > 0.7)
+     * @param date_value
+     * @param interval 形式如:(125%,135%)U(70%,80%)
+     * @param connector 连接符 如:") || ("
+     */
+    private static String getFormulaByAllInterval(String date_value, String interval, String connector) {
+        StringBuffer buff = new StringBuffer();
+        for(String limit:interval.split("U")){//如:(125%,135%)U (70%,80%)
+            buff.append("(").append(getFormulaByInterval(date_value, limit," && ")).append(")").append(connector);
+        }
+        String allLimitInvel = buff.toString();
+        int index = allLimitInvel.lastIndexOf(connector);
+        allLimitInvel = allLimitInvel.substring(0,index);
+        return allLimitInvel;
+    }
+
+    /**
+     * 将整个阀值区间转化为公式:如
+     * 145) =》 date_value < 145
+     * [75,80) =》 date_value < 80 && date_value >= 75
+     * @param date_value
+     * @param interval 形式如:145)、[75,80)
+     * @param connector 连接符 如:&&
+     */
+    private static String getFormulaByInterval(String date_value, String interval, String connector) {
+        StringBuffer buff = new StringBuffer();
+        for(String halfInterval:interval.split(",")){//如:[75,80)、≥80
+            buff.append(getFormulaByHalfInterval(halfInterval, date_value)).append(connector);
+        }
+        String limitInvel = buff.toString();
+        int index = limitInvel.lastIndexOf(connector);
+        limitInvel = limitInvel.substring(0,index);
+        return limitInvel;
+    }
+
+
+    /**
+     * 将半个阀值区间转化为公式:如
+     * 145) =》 date_value < 145
+     * ≥80% =》 date_value >= 0.8
+     * [130 =》 date_value >= 130
+     * <80% =》 date_value < 0.8
+     * @param halfInterval 形式如:145)、≥80%、[130、<80%
+     * @param date_value
+     * @return date_value < 145
+     */
+    private static String getFormulaByHalfInterval(String halfInterval, String date_value) {
+        halfInterval = halfInterval.trim();
+        if(halfInterval.contains("∞")){//包含无穷大则不需要公式
+            return "1 == 1";
+        }
+        StringBuffer formula = new StringBuffer();
+        String data = "";
+        String opera = "";
+        if(halfInterval.matches("^([<>≤≥\\[\\(]{1}(-?\\d+.?\\d*\\%?))$")){//表示判断方向(如>)在前面 如:≥80%
+            opera = halfInterval.substring(0,1);
+            data = halfInterval.substring(1);
+        }else{//[130、145)
+            opera = halfInterval.substring(halfInterval.length()-1);
+            data = halfInterval.substring(0,halfInterval.length()-1);
+        }
+        double value = dealPercent(data);
+        formula.append(date_value).append(" ").append(opera).append(" ").append(value);
+        String a = formula.toString();
+        //转化特定字符
+        return a.replace("[", ">=").replace("(", ">").replace("]", "<=").replace(")", "<").replace("≤", "<=").replace("≥", ">=");
+    }
+
+
+    /**
+     * 去除百分号,转为小数
+     * @param str 可能含百分号的数字
+     * @return
+     */
+    private static double dealPercent(String str){
+        double d = 0.0;
+        if(str.contains("%")){
+            str = str.substring(0,str.length()-1);
+            d = Double.parseDouble(str)/100;
+        }else{
+            d = Double.parseDouble(str);
+        }
+        return d;
+    }
+
+
+    public static void main(String[] args) {
+
+        System.out.println(LinkUtils.isInTheInterval("7", "(-1,9]"));
+    }
+
+
+
 }

+ 15 - 3
module-oa/src/main/java/cn/com/ctop/oa/modules/enums/DepartEnum.java

@@ -8,15 +8,27 @@ public enum DepartEnum {
 
     depart1("快手事业部"),
     depart2("头条事业部"),
-    depart3("销售部"),
+    //    depart3("销售部"),
     depart4("研发中心部"),
-  //  depart5("内容中心部"),
+    //  depart5("内容中心部"),
     depart6("媒介部"),
     depart7("渠道部"),
     depart8("制片部"),
     depart9("法务部"),
     depart10("财务部"),
-    depart11("人事行政部");
+    depart11("人事行政部"),
+    depart12("快手直播销售部"),
+    depart13("头条直播销售部"),
+    depart14("BD"),
+    depart15("业务管理部"),
+    depart16("运营部"),
+    depart161("运营一部"),
+    depart162("运营二部"),
+    //    depart17("聚星事业部"),
+    depart171("视频部"),
+    depart18("销售部");
+//    depart19("销售一部");
+//    depart20("销售二组");
 
 
     private String departName;

+ 2 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/mapper/CtopAccountTransactionDayMapper.java

@@ -10,7 +10,9 @@ import java.util.List;
 public interface CtopAccountTransactionDayMapper {
 
     List<String> getAdvertiserIdByDate(@Param("date") String date, @Param("advertiserId") String advertiserId);
+    void deleteAccountTransactionById( @Param("id") String id);
 
     void saveAccountTransactionDay(@Param("list") List<TransactionDay> list, @Param("date") String date);
+    void replaceAccountTransactionDay(@Param("list") List<TransactionDay> list);
 
 }

+ 27 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/mapper/xml/CtopAccountTransactionDayMapper.xml

@@ -18,13 +18,38 @@
             #{item.sharedWalletCost},
             #{item.transferIn},
             #{item.transferOut},
-            #{date}
+            NOW()
+            )
+        </foreach>
+    </insert>
+ <!-- 批量插入新增数据-->
+    <insert id="replaceAccountTransactionDay">
+        REPLACE into ctop_account_transaction_day (advertiser_id,date,balance,cash_cost,cost,frozen,income,reward_cost,
+        shared_wallet_cost,transfer_in,transfer_out,create_time) values
+        <foreach collection="list" item="item" index="index" separator=",">
+            (
+            #{item.advertiserId},
+            #{item.date},
+            #{item.balance},
+            #{item.cashCost},
+            #{item.cost},
+            #{item.frozen},
+            #{item.income},
+            #{item.rewardCost},
+            #{item.sharedWalletCost},
+            #{item.transferIn},
+            #{item.transferOut},
+            NOW()
             )
         </foreach>
     </insert>
 
     <select id="getAdvertiserIdByDate" parameterType="String" resultType="String">
-        select t.advertiser_id from ctop_account_transaction_day t where t.date=#{date} and t.advertiser_id=#{advertiserId}
+        select t.id from ctop_account_transaction_day t where t.date=#{date} and t.advertiser_id=#{advertiserId} ORDER BY date
+    </select>
+
+    <select id="deleteAccountTransactionById">
+        delete  from ctop_account_transaction_day t where id = #{id}
     </select>
 
 </mapper>

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/mapper/xml/CtopAgentAccountMapper.xml

@@ -21,7 +21,7 @@
    </sql>
     <!--获取所有账户-->
     <select id="getAllAccountId" resultType="String">
-        select account_id from ctop_agent_account where state=0
+       select  account_id  from ctop_user_allocation where media_id in(1,3) and account_status = 0
     </select>
     <!-- 根据账户id修改账户状态-->
     <update id="updateAccountState">

+ 2 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/service/AgentManagementService.java

@@ -5,7 +5,7 @@ import org.jeecg.common.api.vo.Result;
 
 public interface AgentManagementService {
     //获取TOKEN
-    public String getToken();
+    public String getToken(long advertiserId);
 
     //查询代理商下账户
     public  JSONObject selectAgentAdvertiser(int pageNum, int pageSize,String account);
@@ -25,4 +25,5 @@ public interface AgentManagementService {
 
     //同步账户日流水
     public Result synchronousAccountTransactionDay(String startDate, String endDate);
+    public void synchronousAccountTransactionDayNew(String startDate, String endDate,int pageNum, int pageSize);
 }

+ 94 - 5
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/agent/service/impl/AgentManagementServiceImpl.java

@@ -1,6 +1,8 @@
 package cn.com.ctop.toutiao.modules.agent.service.impl;
 
 import cn.com.ctop.common.module.entity.CtopOauthToken;
+import cn.com.ctop.common.module.service.IUserAllocationService;
+import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.toutiao.modules.agent.entity.TransactionDay;
 import cn.com.ctop.toutiao.modules.agent.entity.TransactionDetails;
 import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDayMapper;
@@ -8,7 +10,9 @@ import cn.com.ctop.toutiao.modules.agent.mapper.CtopAccountTransactionDetailsMap
 import cn.com.ctop.toutiao.modules.agent.mapper.CtopAgentAccountMapper;
 import cn.com.ctop.toutiao.modules.agent.service.AgentManagementService;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import javafx.beans.binding.When;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.CloseableHttpResponse;
@@ -18,6 +22,7 @@ import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -77,6 +82,10 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                 for (String account : split) {
                     //分页查询第一页数据
                     JSONObject agentAccountList = selectAgentAdvertiser(1, 2000, account);
+                    if (!Integer.valueOf(agentAccountList.get("code").toString()).equals(0)){
+                        log.info("代理商:{}拉取账户异常--{}",account,agentAccountList);
+                    };
+
                     JSONObject data = (JSONObject) agentAccountList.get("data");
                     //dataList.addAll((List) data.get("list"));
                     if (data.size() > 0) {
@@ -254,9 +263,12 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @author zzy
      * @create: 2021-07-15
      */
+
+    @Autowired
+    private IUserAllocationService userAllocationService;
     @Override
     public Result synchronousAccountTransactionDay(String startDate, String endDate) {
-        log.info("开始同步账号日流水");
+        log.info("开始同步账号日流水---日期{}---{}",startDate,endDate);
         Result result = new Result();
         SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
         Calendar ca = Calendar.getInstance();
@@ -264,7 +276,21 @@ public class AgentManagementServiceImpl implements AgentManagementService {
         ca.add(Calendar.DATE, -1);
 
         try {
-            List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
+            List<Long> list = new ArrayList<>();
+            list.add(13590893L);
+            list.add(13740894L);
+            list.add(13980885L);
+            list.add(14160885L);
+            list.add(14190887L);
+            list.add(14310885L);
+            list.add(11940886L);
+            list.add(13170889L);
+            list.add(13350891L);
+            list.add(14370889L);
+            list.add(14490895L);
+
+            List<String> accountIdList = userAllocationService.getAccountListByProjectV2(list);
+
             if (!accountIdList.isEmpty()) {
                 accountIdList.stream().forEach(str -> {
                     List<TransactionDay> transactionDetailsList = new ArrayList<>();
@@ -291,6 +317,11 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                                 dataList.stream().forEach(ob -> {
                                     TransactionDay transactionDay = JSONObject.toJavaObject((JSON) ob, TransactionDay.class);
                                     List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
+
+                                    if (advertiserIdList.size() > 1){
+                                        ctopAccountTransactionDayMapper.deleteAccountTransactionById(advertiserIdList.get(0));
+                                        log.info("----------->删除重复数据。accountId:{},date:{}",transactionDay.getAdvertiserId(),transactionDay.getDate());
+                                    }
                                     //订单号不存在
                                     if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
                                         transactionDetailsList.add(transactionDay);
@@ -309,6 +340,10 @@ public class AgentManagementServiceImpl implements AgentManagementService {
                                             TransactionDay transactionDay = JSONObject.toJavaObject((JSON) obj, TransactionDay.class);
                                             List<String> advertiserIdList = ctopAccountTransactionDayMapper.getAdvertiserIdByDate(transactionDay.getDate(), transactionDay.getAdvertiserId());
 
+                                            if (advertiserIdList.size() > 1){
+                                                ctopAccountTransactionDayMapper.deleteAccountTransactionById(advertiserIdList.get(0));
+                                            }
+
                                             //订单号不存在
                                             if (advertiserIdList.isEmpty() || advertiserIdList.size() <= 0) {
                                                 transactionDetailsList.add(transactionDay);
@@ -338,6 +373,59 @@ public class AgentManagementServiceImpl implements AgentManagementService {
 
 
         return result;
+    } /**
+     * 同步账户日流水
+     *
+     * @author zzy
+     * @create: 2021-07-15
+     */
+    @Override
+    public void synchronousAccountTransactionDayNew(String startDate, String endDate,int page, int pageSize) {
+
+        List<TransactionDay> list = new ArrayList<>();
+        List<String> accountIdList = ctopAgentAccountMapper.getAllAccountId();
+
+//        List<String> accountIdList = new ArrayList<>();
+//        accountIdList.add("1735775204994062");
+//        accountIdList.add("1744114166675533");
+//        accountIdList.add("1744114166069261");
+
+        for (String accountId : accountIdList) {
+            page = 1;
+            log.info("同步头条账户流水信息{}:开始时间{},结束时间{},第{}页" ,accountId,startDate,endDate,page);
+
+            JSONObject jsonObject = queryAccountTransactionDay(accountId, page, 1000, startDate, endDate);
+            JSONObject data = null;
+            int code = 1;
+            if (jsonObject != null) {
+                data = (JSONObject) jsonObject.get("data");
+                code = (int) jsonObject.get("code");
+            } else {
+                log.info("头条账户流水信心为空,数据jsonObject为null");
+                continue;
+            }
+            if (code != 0) {
+                log.info("获取头条账户流水返回数据:" + jsonObject.toJSONString() + ":" + accountId);
+                continue;
+            }
+            if (data != null) {
+                List<Object> dataList = (List<Object>) data.get("list");
+                if (dataList != null && !dataList.isEmpty()) {
+                    dataList.stream().forEach(ob -> {
+                        TransactionDay transactionDay = JSONObject.toJavaObject((JSON) ob, TransactionDay.class);
+                        list.add(transactionDay);
+                    });
+                }
+            }
+            ctopAccountTransactionDayMapper.replaceAccountTransactionDay(list);
+            log.info("获取头条账户:{}流水信息{}条" ,accountId,list.size());
+            page++;
+            int totalPage = jsonObject.getJSONObject("data").getJSONObject("page_info").getInteger("total_page");
+            if (page <= totalPage) {
+                synchronousAccountTransactionDayNew(startDate, endDate, page, 1000);
+            }
+        }
+
     }
 
     /**
@@ -401,8 +489,9 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @create: 2021-07-14
      */
     @Override
-    public String getToken() {
-        CtopOauthToken ctopOauthToken = ctopAgentAccountMapper.selectByAccountId(Long.parseLong(ADVERTISER_ID));
+    public String getToken(long advertiserId) {
+//        CtopOauthToken ctopOauthToken = ctopAgentAccountMapper.selectByAccountId(Long.parseLong(ADVERTISER_ID));
+        CtopOauthToken ctopOauthToken = ctopAgentAccountMapper.selectByAccountId(advertiserId);
         if (ctopOauthToken != null) {
             return ctopOauthToken.getAccessToken();
         } else {
@@ -441,7 +530,7 @@ public class AgentManagementServiceImpl implements AgentManagementService {
      * @create: 2021-07-14
      */
     public JSONObject sendHttpRequest(Map data, String apiUrl) {
-        String access_token = getToken();
+        String access_token = getToken(Long.parseLong(data.get("advertiser_id").toString()));
         // 构造请求
         HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
             @Override

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

@@ -1,6 +1,7 @@
 package cn.com.ctop.toutiao.modules.material.entity;
 
 import cn.com.ctop.common.module.annotation.Dict;
+import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -216,6 +217,12 @@ public class ByteDanceAdvertisePlan {
     @TableField(exist=false)
     private String useOpenUrl;
 
+
+    //点击监测链接
+    private String actionTrackUrl;
+
+
+
     public ByteDanceAdvertisePlan(JSONObject dataObject, String accountId) {
         this.id = dataObject.getLong("id");
         this.accountId = accountId;
@@ -391,6 +398,10 @@ public class ByteDanceAdvertisePlan {
         if (null != externalUrl && !"".equals(externalUrl.trim())) {
             this.externalUrl = externalUrl;
         }
+        JSONArray action_track_url = dataObject.getJSONArray("action_track_url");
+        if (!Check.isNull(action_track_url)){
+            this.actionTrackUrl = action_track_url.getString(0);
+        }
     }
 
     public ByteDanceAdvertisePlan(String advertiserId, Long adId, JSONObject params) {

+ 3 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/BytedanceImageInfoMapper.java

@@ -17,11 +17,11 @@ public interface BytedanceImageInfoMapper extends BaseMapper<BytedanceImageInfo>
     void replaceBatch(@Param(value = "imageInfos")List<BytedanceImageInfo> imageInfos);
 
     //大图横图
-    void updateImageHorizonType();
+    void updateImageHorizonType(Long accountId);
     //大图竖图
-    void updateImageVerticalType();
+    void updateImageVerticalType(Long accountId);
     //开屏
-    void updateImageUnionType();
+    void updateImageUnionType(Long accountId);
     //开屏 或者 竖图
     //void updateImageUnionIOrVerticalType();
 }

+ 12 - 3
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/mapper/xml/BytedanceImageInfoMapper.xml

@@ -48,8 +48,11 @@
         update
             ctop_bytedance_image_info
         set type = 3
-        where width &lt; height and type is null or type = 2
-            and width = 1080 and height = 1920
+        where width = 1080 and height = 1920
+        <if test="accountId !=null and accountId != ''">
+            and account_id = #{accountId}
+        </if>
+
     </update>
     <!-- 大图竖图 -->
     <update id="updateImageVerticalType">
@@ -57,7 +60,10 @@
             ctop_bytedance_image_info
         set type = 2
         where height &gt; width and type is null
-        and (height between 1280 and 2560)  and (width between 720 and 1440);
+        and (height between 1280 and 2560)  and (width between 720 and 1440)
+        <if test="accountId !=null and accountId != ''">
+            and account_id = #{accountId}
+        </if>
     </update>
     <!-- 大图横图 -->
     <update id="updateImageHorizonType">
@@ -65,5 +71,8 @@
             set type = 1
         where height &lt; width and type is null
         and (width between 1280 and 2560)  and (height between 720 and 1440)
+        <if test="accountId !=null and accountId != ''">
+            and account_id = #{accountId}
+        </if>
     </update>
 </mapper>

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

@@ -17,5 +17,5 @@ public interface IBytedanceImageInfoService extends IService<BytedanceImageInfo>
     /**
      * 清洗图片素材类型
      */
-    void updateType();
+    void updateType(Long accountId);
 }

+ 5 - 2
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -242,6 +242,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
                 advertisePlan.setDeepCpaBid(deepCpabid);
             }
             advertisePlanService.saveOrUpdate(advertisePlan);
+            //log.info("============保存头条计划=================");
         }
         getAd(token, pageNum + 1, ids, date, updateDate);
     }
@@ -644,6 +645,8 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         updaBytedanceVideoByAccountId(token);
         getVideoByPage(token, "", 1);
         getImageByPage(token, "", 1);
+        //修改图片类型
+        imageInfoService.updateType(token.getAccountId());
     }
 
     @Autowired
@@ -681,7 +684,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
         JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
         if (null == data || data.isEmpty()) {
-            log.info("获取图片素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
+            log.info("获取头条图片素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
             return;
         }
         List<BytedanceImageInfo> videoInfoList = new ArrayList<>();
@@ -725,7 +728,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
         }
         JSONArray data = resultObject.getJSONObject("data").getJSONArray("list");
         if (null == data || data.isEmpty()) {
-            log.info("获取视频素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
+            log.info("获取头条视频素材完成==》accountId:{},message:{}", token.getAccountId(), resultObject.getString("message"));
             return;
         }
         List<ByteDanceVideoInfo> videoInfoList = new ArrayList<>();

+ 7 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/BytedanceImageInfoServiceImpl.java

@@ -4,6 +4,7 @@ import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
 import cn.com.ctop.toutiao.modules.material.mapper.BytedanceImageInfoMapper;
 import cn.com.ctop.toutiao.modules.material.service.IBytedanceImageInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -17,6 +18,7 @@ import java.util.List;
  * @version V1.0
  */
 @Service
+@Slf4j
 public class BytedanceImageInfoServiceImpl extends ServiceImpl<BytedanceImageInfoMapper, BytedanceImageInfo> implements IBytedanceImageInfoService {
     @Resource
     private BytedanceImageInfoMapper imageInfoMapper;
@@ -26,13 +28,14 @@ public class BytedanceImageInfoServiceImpl extends ServiceImpl<BytedanceImageInf
     }
 
     @Override
-    public void updateType() {
+    public void updateType(Long accountId) {
         //大图竖图 -2
-        imageInfoMapper.updateImageVerticalType();
+        imageInfoMapper.updateImageVerticalType(accountId);
         //大图横图 -1
-        imageInfoMapper.updateImageHorizonType();
+        imageInfoMapper.updateImageHorizonType(accountId);
         //开屏-3
-        imageInfoMapper.updateImageUnionType();
+        imageInfoMapper.updateImageUnionType(accountId);
+        log.info("清洗头条图片类型成功=====>>>>>accountId:{}",accountId);
         //开屏 或者 竖图 -4
         //imageInfoMapper.updateImageUnionIOrVerticalType();
     }

module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/BytedanceAdvertiserHourlyReportMapper.xml → module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/report/mapper/xml/KuaishouSupplyChainMapper.xml


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

@@ -562,6 +562,7 @@ public class ReportServiceImpl implements IReportService {
         conditions.setEndDate(DateUtils.formatDate(endDate));
         conditions.setPageSize(1000);
         conditions.setTimeGranularity(bytedanceReportTypePl);
+        conditions.setFields(conditions.getFieldsList());
         return conditions;
     }
 

+ 1 - 1
pom.xml

@@ -198,7 +198,7 @@
         <dependency>
             <groupId>com.alibaba</groupId>
             <artifactId>fastjson</artifactId>
-            <version>1.2.56</version>
+            <version>1.2.83</version>
         </dependency>
 
         <dependency>