Переглянути джерело

Merge remote-tracking branch 'origin/master'

jiequan.bi 4 роки тому
батько
коміт
ac03ddfe6c

+ 14 - 4
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -8,11 +8,11 @@ import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouDailyReportTaskService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouAgentAccount;
 import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouAgentAccountMapper;
 import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
-import cn.com.ctop.toutiao.modules.report.service.IByteDanceVideoReportDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceFundDailyService;
 import cn.com.ctop.toutiao.modules.report.service.IBytedanceReportService;
 import cn.com.ctop.toutiao.modules.report.service.IReportService;
@@ -32,6 +32,8 @@ import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import java.math.BigDecimal;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
@@ -272,7 +274,18 @@ public class SampleTest {
             }
         }
     }
+    @Autowired
+    private IKuaishouInterfaceService kuaishouInterfaceService;
 
+    @Test
+    public void loadKuaishouGroupData() throws ParseException {
+        Date endDate = new Date();
+        String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", DateUtils.formatDate(endDate), -1);
+        SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
+        Date startDate = sim.parse(anotherDay);
+        CtopOauthToken token = tokenService.getTokenByAccountId(7087890L);
+        kuaishouInterfaceService.getGroupList(token, startDate, endDate);
+    }
 
 
 
@@ -308,9 +321,6 @@ public class SampleTest {
 
     @Autowired
     private IBytedanceReportService bytedanceReportService;
-
-    @Autowired
-    private IByteDanceVideoReportDailyService videoReportDailyService;
     @Test
     public void loadMatData(){
         List<UserAllocation> allocations = allocationService.getByParams(289L,null,0);

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

@@ -34,7 +34,7 @@ public interface ICtopOauthTokenService extends IService<CtopOauthToken> {
 
     List<CtopOauthToken> getToutiaoTokenByCreateTime(String createTime);
 
-    List<CtopOauthToken> getByProjectId(long projectId);
+    List<CtopOauthToken> getByProjectId(Long projectId);
 
     CtopOauthToken selectOneByMediaId(String platformTypeKuaishou);
 

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

@@ -223,7 +223,7 @@ public class CtopOauthTokenServiceImpl extends ServiceImpl<CtopOauthTokenMapper,
     }
 
     @Override
-    public List<CtopOauthToken> getByProjectId(long projectId) {
+    public List<CtopOauthToken> getByProjectId(Long projectId) {
         QueryWrapper<CtopOauthToken> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("project_id", projectId).eq("account_status", 0);
         return this.list(queryWrapper);

+ 2 - 2
module-job-kuaishou/src/main/resources/application-prod.yml

@@ -98,7 +98,7 @@ spring:
   #redis 配置
   redis:
     database: 0
-    host: 127.0.0.1
+    host: 172.30.0.17
     lettuce:
       pool:
         max-active: 8   #最大连接数据库连接数,设 0 为没有限制
@@ -106,7 +106,7 @@ spring:
         max-wait: -1ms  #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
         min-idle: 0     #最小等待连接中的数量,设 0 为没有限制
       shutdown-timeout: 100ms
-    password: ''
+    password: foobared
     port: 6379
 #mybatis plus 设置
 mybatis-plus:

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

@@ -190,6 +190,124 @@ public class CrossAccountBatchController {
     }
 
 
+
+
+
+    /**
+     * 批量创建广告组
+     *
+     * @param requestJson
+     * @return
+     */
+    @PostMapping(value = "/batchUnitCreate")
+    public Result<JSONArray> batchUnitCreate(@RequestBody JSONObject requestJson) {
+        Result<JSONArray> result = new Result<>();
+        try {
+            System.err.println(requestJson);
+            JSONArray accountArr = requestJson.getJSONArray("accountArr");
+            if (Check.isNull(accountArr)) {
+                throw new Exception("请选择需要创建的账户");
+            }
+            JSONArray returnArr = new JSONArray();
+
+            for (int i = 0; i < accountArr.size(); i++) {
+                Long accountId = accountArr.getLong(i);
+                CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
+                if (Check.isNull(oauthToken)) {
+                    throw new Exception("未获取到账户信息");
+                }
+
+                JSONObject returnJson = new JSONObject();
+                returnJson.put("accountId", accountId);
+                JSONObject campaignJson = new JSONObject();
+                campaignJson.put("day_budget", requestJson.getLong("dayBudget"));
+                Integer nameType = requestJson.getInteger("nameType");
+                Integer type = requestJson.getInteger("type");
+                campaignJson.put("type", type);
+                if (!Check.isNull(requestJson.getLong("dayBudget"))) {
+                    campaignJson.put("day_budget", requestJson.getLong("dayBudget"));
+                }
+
+                if (!Check.isNull(requestJson.getJSONArray("dayBudgetSchedule"))) {
+                    campaignJson.put("day_budget_schedule", requestJson.getJSONArray("dayBudgetSchedule"));
+                }
+
+                JSONArray campaignNames = new JSONArray();
+                if (nameType == 0) { // 0 为统一命名  1 为分别命名
+                    //    Integer startNum = requestJson.getInteger("startNum");
+                    Integer createTotal = requestJson.getInteger("createTotal");
+                    String campaignName = requestJson.getString("campaignName");
+                    for (int j = 0; j < createTotal; j++) {
+                        if (campaignName.contains("{{数值}}")) {
+                            String name = getName(campaignName, accountId, j, type);
+                            campaignNames.add(name);
+                        } else {
+                            String name = null;
+                            if (createTotal == 1) {
+                                name = getName(campaignName, accountId, null, type);
+                            } else {
+                                name = getName(campaignName + "_" + j, accountId, null, type);
+                            }
+                            campaignNames.add(name);
+                        }
+                    }
+                } else if (nameType == 1) { // "分别命名"
+                    JSONArray nameArr = requestJson.getJSONArray("nameArr");
+                    for (int j = 0; j < nameArr.size(); j++) {
+                        JSONObject nameJson = nameArr.getJSONObject(j);
+                        if (nameJson.getLong("accountId").equals(accountId)) {
+                            campaignNames = nameJson.getJSONArray("campaignNames");
+                        }
+                    }
+                }
+                if (!Check.isNull(campaignNames)) {
+                    JSONArray returnCampaigns = new JSONArray();
+                    for (int j = 0; j < campaignNames.size(); j++) {
+                        JSONObject returnCampaignJson = new JSONObject();
+                        String campaignName = (String) campaignNames.get(j);
+                        campaignJson.put("campaign_name", campaignName);
+                        Map<String, Object> campaignMap = kuaishouInterfaceService.campaignCreate(oauthToken.getAccessToken(), accountId, campaignJson);
+                        if ((Integer) campaignMap.get("code") == 0) {
+                            returnCampaignJson.put("code", 0);
+                            returnCampaignJson.put("campaignId", campaignMap.get("campaignId"));
+                            returnCampaignJson.put("campaignName", campaignName);
+                            returnCampaignJson.put("type", type);
+                            returnCampaignJson.put("message", campaignMap.get("message"));
+                        } else {
+                            returnCampaignJson.put("code", -1);
+                            returnCampaignJson.put("campaignName", campaignName);
+                            returnCampaignJson.put("message", campaignMap.get("message"));
+                        }
+                        returnCampaigns.add(returnCampaignJson);
+
+                    }
+                    returnJson.put("createDetail", returnCampaigns);
+
+                }
+                returnArr.add(returnJson);
+            }
+            result.setSuccess(true);
+            System.err.println(returnArr);
+            result.setResult(returnArr);
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+            result.setMessage(e.getMessage());
+
+        }
+        return result;
+
+    }
+
+
+
+
+
+
+
+
+
+
     /**
      * @param content   计划名称
      * @param accountId 账户id

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

@@ -420,7 +420,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("end_date", DateUtils.formatDate(endDate));
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "HOURLY");
-        param.put("page_size", 500);
+        param.put("page_size", 2000);
         param.put("page", page);
 
         String result = HttpUtils.httpPostRequest(url, param, headers);
@@ -588,7 +588,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("end_date", DateUtils.formatDate(endDate));
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "HOURLY");
-        param.put("page_size", 500);
+        param.put("page_size", 2000);
         param.put("page", page);
 
         String result = HttpUtils.httpPostRequest(url, param, headers);
@@ -686,6 +686,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("page_size", 1000);
         param.put("page", page);
 
+
         String result = HttpUtils.httpPostRequest(url, param, headers);
         JSONObject resultJson = JSONObject.parseObject(result);
         Integer code = resultJson.getInteger("code");
@@ -796,7 +797,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         param.put("end_date", DateUtils.formatDate(endDate));
         param.put("advertiser_id", token.getAccountId());
         param.put("temporal_granularity", "HOURLY");
-        param.put("page_size", 200);
+        param.put("page_size", 2000);
         param.put("page", page);
 
         String result = HttpUtils.httpPostRequest(url, param, headers);

+ 1 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyCreativeMapper.xml

@@ -283,7 +283,7 @@
 
 
     <select id="checkZombieProject" resultType="com.alibaba.fastjson.JSONObject">
-      SELECT *FROM
+      SELECT * FROM
 		(SELECT
 			count(t1.stat_date) AS dates,
 			sum(t1.charge) AS charge,

+ 4 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/report/mapper/xml/KuaishouReportDailyImageMapper.xml

@@ -107,7 +107,7 @@
     <select id="imageCost" resultType="cn.com.ctop.common.module.vo.KuaishouImageCostVO">
         select
         report.cover_url as 'image_url' ,
-        report.code as 'signature',
+        report.cover_id as 'signature',
         group_concat(distinct p.project_name) AS 'project_name',
         sum(report.charge) AS 'charge',
         sum(report.photo_click) AS 'photo_click',
@@ -125,7 +125,7 @@
         where
             1=1
         and
-            report.code is not null
+            report.cover_id is not null
         <if test="startDate!=null">
             and report.stat_date &gt;= #{startDate}
         </if>
@@ -139,9 +139,9 @@
             </foreach>
         </if>
         <if test="code!=null">
-            and report.code = #{code}
+            and report.cover_id = #{code}
         </if>
-        group by report.code
+        group by report.cover_id
         order by sum(report.charge) desc
     </select>
     <select id="imageCostEntity" resultType="cn.com.ctop.common.module.vo.KuaishouImageCostVOEntity">

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

@@ -43,7 +43,6 @@ public class ByteDanceVideoReportDailyServiceImpl extends ServiceImpl<ByteDanceV
         videoInfoListByCompanyId(startDate, endDate, "d57fecdcf7a94d009736d9c850731582");
         //华东
         videoInfoListByCompanyId(startDate, endDate, "4b10089775c040119e139087517aed88");
-
     }
 
     private void videoInfoListByCompanyId(String startDate, String endDate, String companyId){