syh 5 лет назад
Родитель
Сommit
dbf18e8138

+ 1 - 1
.gitignore

@@ -32,4 +32,4 @@ gen
 # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
 hs_err_pid*
 **/target/
-#application.yml
+application.yml

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

@@ -64,12 +64,6 @@
             <artifactId>commons-csv</artifactId>
             <version>1.5</version>
         </dependency>
-
-        <dependency>
-            <groupId>cn.edu.hfut.dmic.webcollector</groupId>
-            <artifactId>WebCollector</artifactId>
-            <version>2.52</version>
-        </dependency>
     </dependencies>
 
     <build>

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

@@ -211,6 +211,17 @@ public class ByteDanceTemplateController {
     }
 
     /**
+     * @param accountId
+     * @param urlId     链接id
+     * @return 查询计划可用转化id
+     */
+    @GetMapping(value = "convert/list/url")
+    public Map<String, Object> convertListByUrlId(Long accountId, Long urlId) {
+        return planService.getAdConvertListByUrlId(accountId, urlId);
+    }
+
+
+    /**
      * @param req
      * @return
      * @功能:获取头条行业信息列表

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

@@ -4,9 +4,12 @@ import com.alibaba.fastjson.JSONObject;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.Map;
+
 @RestController
 @RequestMapping("/test")
 public class TestController {
@@ -14,9 +17,7 @@ public class TestController {
     private ICreateInternalService createInternalService;
 
     @PostMapping(value = "/create")
-    public void authorization() {
-        JSONObject json = new JSONObject();
-        System.err.println(json);
-        createInternalService.createInternal(json);
+    public Map<String, Object> authorization(@RequestBody JSONObject jsonObject) {
+        return createInternalService.createInternal(jsonObject);
     }
 }

+ 142 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/mapper/xml/PlatformCampaignStatisticInfoMapper.xml

@@ -9,7 +9,7 @@
         <result column="content" property="content"/>
         <result column="meterial" property="meterial"/>
         <result column="priceType" property="priceType"/>
-        <result column="directCondition" property="directCondition"/>
+		<result column="directCondition" property="directCondition"/>
         <result column="basicDirect" property="basicDirect"/>
         <result column="cost" property="cost"/>
         <result column="coverViews" property="coverViews"/>
@@ -23,13 +23,13 @@
         <result column="completeRate" property="completeRate"/>
         <result column="materialViews" property="materialViews"/>
         <result column="actions" property="actions"/>
-        <result column="clickRate" property="clickRate"/>
+		<result column="clickRate" property="clickRate"/>
         <result column="actionClickRate" property="actionClickRate"/>
         <result column="abctr" property="abctr"/>
         <result column="clickPrice" property="clickPrice"/>
         <result column="actionPrice" property="actionPrice"/>
         <result column="registUserNum" property="registUserNum"/>
-        <result column="complateUserNum" property="complateUserNum"/>
+		<result column="complateUserNum" property="complateUserNum"/>
         <result column="creditUserNum" property="creditUserNum"/>
         <result column="registCompleteNum" property="registCompleteNum"/>
         <result column="registCreditNum" property="registCreditNum"/>
@@ -38,7 +38,7 @@
         <result column="creditPrice" property="creditPrice"/>
         <result column="registCompletePrice" property="registCompletePrice"/>
         <result column="registCreditPrice" property="registCreditPrice"/>
-        <result column="clickRegistRate" property="clickRegistRate"/>
+		<result column="clickRegistRate" property="clickRegistRate"/>
         <result column="actionRegistRate" property="actionRegistRate"/>
     </resultMap>
 
@@ -269,9 +269,146 @@ FROM
 			ctop_kuaishou_platform_campaign_statistic_info AS c
 		WHERE
 			c.account_id = #{accountId}
-			and c.statistic_date = #{statisticDate}
+			and c.statistic_date = #{statisticDate} and c.cost!=0
 		ORDER BY
 			c.campaign_info
 	) AS h
     </select>
+
+	<select id="sumZeroVoByParams" resultMap="voMap">
+SELECT
+	'2019/8/28' AS 'statisticDate',
+			'汇创思拓' AS 'proxy',
+			'消费0用户统计信息' as 'channelName',
+			'消费0用户' AS 'content',
+	SUM(a.cost) AS 'cost',
+	SUM(a.coverViews) AS 'coverViews',
+	SUM(a.coverClick) AS 'coverClick',
+	SUM(a.materialViews) AS 'materialViews',
+	SUM(a.actions) AS'actions',
+	SUM(a.coverClick) / SUM(a.coverViews) * 100 AS 'clickRate',
+	SUM(a.actions) / SUM(a.coverClick) * 100 AS 'actionClickRate',
+	SUM(a.actions) / SUM(a.coverClick) * SUM(a.coverClick) / SUM(a.coverViews) * 10000 AS 'abctr',
+	SUM(a.cost) / SUM(a.coverClick) 'clickPrice',
+	SUM(a.cost) / SUM(a.actions) 'actionPrice',
+	sum(a.registUserNum) AS 'registUserNum',
+	sum(a.complateUserNum) AS 'complateUserNum',
+	sum(a.creditUserNum) AS 'creditUserNum',
+	sum(a.registCompleteNum) AS 'registCompleteNum',
+	sum(a.registCreditNum) AS 'registCreditNum',
+	SUM(a.cost) / sum(a.registUserNum) AS 'registPrice',
+	SUM(a.cost) / sum(a.complateUserNum) AS 'completePrice',
+	SUM(a.cost) / sum(a.creditUserNum) AS 'creditPrice',
+	SUM(a.cost) / sum(a.registCompleteNum) AS 'registCompletePrice',
+	SUM(a.cost) / sum(a.registCreditNum) AS 'registCreditPrice',
+	sum(a.registUserNum) / SUM(a.coverClick) * 100 AS 'clickRegistRate',
+	sum(a.registUserNum) / SUM(a.actions) * 100 AS 'actionRegistRate',
+	sum(a.complateUserNum) / sum(a.registUserNum) * 100 AS 'completeRate',
+	sum(a.creditUserNum) / sum(a.complateUserNum) * 100 AS 'creditRate',
+	sum(a.registCompleteNum) / sum(a.registUserNum) * 100 AS 'registCompleteRate',
+	sum(a.creditUserNum) / sum(a.complateUserNum) * 100 AS 'registCreditRate',
+	sum(a.registCompleteNum) / sum(a.complateUserNum) * 100 AS 'completeRateDay',
+	sum(a.registCreditNum) / sum(a.creditUserNum) * 100 AS 'creditRateDay',
+	sum(a.registCreditNum) / sum(a.registUserNum) * 100 AS 'creditRegistRateDay'
+FROM
+	(
+	SELECT
+	h.*, h.cost / h.registUserNum AS 'registPrice',
+	h.cost / h.complateUserNum AS 'completePrice',
+	h.cost / h.creditUserNum AS 'creditPrice',
+	h.cost / h.registCompleteNum AS 'registCompletePrice',
+	h.cost / h.registCreditNum AS 'registCreditPrice',
+	h.registUserNum / h.coverClick * 100 AS 'clickRegistRate',
+	h.registUserNum / h.actions * 100 AS 'actionRegistRate',
+	h.complateUserNum / h.registUserNum * 100 AS 'completeRate',
+	h.creditUserNum / h.complateUserNum * 100 AS 'creditRate',
+	h.registCompleteNum / h.registUserNum * 100 AS 'registCompleteRate',
+	h.creditUserNum / h.complateUserNum * 100 AS 'registCreditRate',
+	h.registCompleteNum / h.complateUserNum * 100 AS 'completeRateDay',
+	h.registCreditNum / h.creditUserNum * 100 AS 'creditRateDay',
+	h.registCreditNum / h.registUserNum * 100 AS 'creditRegistRateDay'
+FROM
+	(
+		SELECT
+			c.statistic_date AS 'statisticDate',
+			'汇创思拓' AS 'proxy',
+			(
+				SELECT
+					a44.child_channel
+				FROM
+					ctop_kuaishou_customer_plan_statistic_info a44
+				WHERE
+					a44.statistic_date = #{statisticDate}
+				AND a44.campaign_code = c.campaign_code
+				ORDER BY
+					a44.id DESC
+				LIMIT 1
+			) AS 'channelName',
+			c.campaign_info AS 'content',
+			c.cost AS 'cost',
+			c.cover_exposure AS 'coverViews',
+			c.cover_click AS 'coverClick',
+			c.metarial_exposure AS 'materialViews',
+			c.action AS 'actions',
+			c.cover_click / c.cover_exposure * 100 AS 'clickRate',
+			c.action / c.cover_click * 100 AS 'actionClickRate',
+			c.action / c.cover_click * c.cover_click / c.cover_exposure * 10000 AS 'abctr',
+			c.cost / c.cover_click 'clickPrice',
+			c.cost / c.action 'actionPrice',
+			(
+				SELECT
+					SUM(a1.regist_account_num)
+				FROM
+					ctop_kuaishou_customer_plan_statistic_info a1
+				WHERE
+					a1.statistic_date = #{statisticDate}
+				AND a1.campaign_code = c.campaign_code
+			) AS 'registUserNum',
+			(
+				SELECT
+					SUM(a2.complete_user)
+				FROM
+					ctop_kuaishou_customer_plan_statistic_info a2
+				WHERE
+					a2.statistic_date = #{statisticDate}
+				AND a2.campaign_code = c.campaign_code
+			) AS 'complateUserNum',
+			(
+				SELECT
+					SUM(a3.estimated_credit_number)
+				FROM
+					ctop_kuaishou_customer_plan_statistic_info a3
+				WHERE
+					a3.statistic_date = #{statisticDate}
+				AND a3.campaign_code = c.campaign_code
+			) AS 'creditUserNum',
+			(
+				SELECT
+					SUM(a4.regist_complate_number)
+				FROM
+					ctop_kuaishou_customer_plan_statistic_info a4
+				WHERE
+					a4.statistic_date = #{statisticDate}
+				AND a4.campaign_code = c.campaign_code
+			) AS 'registCompleteNum',
+			(
+				SELECT
+					SUM(
+						a5.estimated_regist_credit_number
+					)
+				FROM
+					ctop_kuaishou_customer_plan_statistic_info a5
+				WHERE
+					a5.statistic_date = #{statisticDate}
+				AND a5.campaign_code = c.campaign_code
+			) AS 'registCreditNum'
+		FROM
+			ctop_kuaishou_platform_campaign_statistic_info AS c
+		WHERE
+			c.account_id = #{accountId} AND c.cost = 0
+			and c.statistic_date = #{statisticDate}
+		ORDER BY
+			c.campaign_info
+	) AS h) AS a
+    </select>
 </mapper>

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

@@ -17,4 +17,6 @@ public interface IByteDanceAdvertisePlanService extends IService<ByteDanceAdvert
     Map<String, Object> advertiserPlanCreate(CTopOauthToken token, Long campaignId, String dataString);
 
     Map<String, Object> getAdConvertList(Long accountId, Long targetId);
+
+    Map<String, Object> getAdConvertListByUrlId(Long accountId, Long urlId);
 }

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

@@ -12,9 +12,11 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.jeecg.modules.ctop.entity.ByteDanceAdvertisePlan;
 import org.jeecg.modules.ctop.entity.BytedanceDeliveryTargetTemplate;
+import org.jeecg.modules.ctop.entity.BytedanceUrlInfo;
 import org.jeecg.modules.ctop.entity.CTopOauthToken;
 import org.jeecg.modules.ctop.mapper.ByteDanceAdvertisePlanMapper;
 import org.jeecg.modules.ctop.mapper.BytedanceDeliveryTargetTemplateMapper;
+import org.jeecg.modules.ctop.mapper.BytedanceUrlInfoMapper;
 import org.jeecg.modules.ctop.service.IByteDanceAdvertisePlanService;
 import org.jeecg.modules.ctop.service.ICTopOauthTokenService;
 import org.slf4j.Logger;
@@ -74,6 +76,79 @@ public class ByteDanceAdvertisePlanServiceImpl extends ServiceImpl<ByteDanceAdve
         return getAdConvert(token, targetTemplate);
     }
 
+    @Override
+    public Map<String, Object> getAdConvertListByUrlId(Long accountId, Long urlId) {
+        CTopOauthToken token = tokenService.getOauthTokenByAccountId(accountId + "");
+        BytedanceUrlInfo urlInfo = urlInfoMapper.selectById(urlId);
+        return getAdConvertByUrlInfo(token, urlInfo);
+    }
+
+    private Map<String, Object> getAdConvertByUrlInfo(CTopOauthToken token, BytedanceUrlInfo urlInfo) {
+        String accessToken = token.getAccessToken();
+        final Long advertiserId = token.getAccountId();
+        // 请求地址
+        String url = "https://ad.toutiao.com/open_api/2/tools/ad_convert/select/";
+
+        // 请求参数
+        Map data = new HashMap() {
+            {
+                put("advertiser_id", advertiserId);
+            }
+        };
+        //落地页或IOS下载链接
+        if ("page".equals(urlInfo.getType()) || "page".equals(urlInfo.getType())) {
+            data.put("external_url", urlInfo.getUrl());
+        }
+        //安卓下载链接
+        if ("android".equals(urlInfo.getType())) {
+            data.put("package_name", urlInfo.getPackageName());
+        }
+
+        // 构造请求
+        HttpEntityEnclosingRequestBase httpEntity = new HttpEntityEnclosingRequestBase() {
+            @Override
+            public String getMethod() {
+                return "GET";
+            }
+        };
+        httpEntity.setHeader("Access-Token", accessToken);
+        CloseableHttpResponse response = null;
+        CloseableHttpClient client = null;
+        try {
+            client = HttpClientBuilder.create().build();
+            httpEntity.setURI(URI.create(url));
+            httpEntity.setEntity(new StringEntity(JSONObject.toJSONString(data), ContentType.APPLICATION_JSON));
+            response = client.execute(httpEntity);
+            if (response != null && response.getStatusLine().getStatusCode() == 200) {
+                BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
+                StringBuffer result = new StringBuffer();
+                String line = "";
+                while ((line = bufferedReader.readLine()) != null) {
+                    result.append(line);
+                }
+                bufferedReader.close();
+                return JSONObject.parseObject(result.toString());
+            }
+        } catch (ClientProtocolException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (response != null) {
+                    response.close();
+                }
+                client.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    @Autowired
+    private BytedanceUrlInfoMapper urlInfoMapper;
+
     @Autowired
     private BytedanceDeliveryTargetTemplateMapper deliveryTargetTemplateMapper;
 

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

@@ -1,6 +1,6 @@
 package org.jeecg.modules.ctop.service.impl;
 
-import cn.com.ctop.common.utils.HttpUtils;
+import cn.com.ctop.common.utils.HttpUtils2;
 import cn.com.ctop.crawler.modules.core.util.FateadmHttpUtil;
 import cn.com.ctop.crawler.modules.core.util.FateadmUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -8,6 +8,10 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.apache.http.impl.cookie.BasicClientCookie;
+import org.jeecg.common.util.ResultMapUtils;
+import org.jeecg.common.util.StatusCode;
+import org.jeecg.modules.ctop.entity.BytedanceUrlInfo;
+import org.jeecg.modules.ctop.mapper.BytedanceUrlInfoMapper;
 import org.jeecg.modules.ctop.service.ICreateInternalService;
 import org.openqa.selenium.Cookie;
 import org.openqa.selenium.WebDriver;
@@ -15,6 +19,7 @@ import org.openqa.selenium.chrome.ChromeDriver;
 import org.openqa.selenium.chrome.ChromeOptions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import sun.misc.BASE64Decoder;
@@ -27,29 +32,30 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
 
     @Value("${jeecg.path.chrome-driver}")
     private String chromeDriver;
-
+    @Autowired
+    private BytedanceUrlInfoMapper urlInfoMapper;
     @Override
     public Map<String, Object> createInternal(JSONObject requestJson) {
+        Map<String, Object> resultMap = new HashMap<>();
         String url = "https://ad.oceanengine.com/pages/login/index.html";
         System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
         ChromeOptions chromeOptions = new ChromeOptions();
-//        chromeOptions.addArguments("--headless");
+        chromeOptions.addArguments("--headless");
 //        chromeOptions.addArguments("--incognito");
         chromeOptions.addArguments("--no-sandbox");
 //        chromeOptions.addArguments("--disable-gpu");
         chromeOptions.addArguments("--window-size=1920,1080");
-        chromeOptions.addArguments("--user-agent=" + HttpUtils.USER_AGENT);
+        chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
         chromeOptions.setAcceptInsecureCerts(true);
         WebDriver webDriver = new ChromeDriver(chromeOptions);
         try {
-
             webDriver.get(url);  //获取登录页面
             for (Cookie cookie : webDriver.manage().getCookies()) {
                 BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
                 ck.setDomain("ad.oceanengine.com");
                 ck.setExpiryDate(cookie.getExpiry());
                 ck.setPath(cookie.getPath());
-                HttpUtils.cookieStore.addCookie(ck);
+                HttpUtils2.cookieStore.addCookie(ck);
             }
             String html = webDriver.getPageSource();
             Map<String, String> header = new HashMap<String, String>();
@@ -67,8 +73,7 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
             param.put("captcha", "hqde");
             param.put("is_30_days_no_login", "true");
             param.put("service", "https://ad.oceanengine.com");
-            String res = HttpUtils.httpPostParamRequest("https://sso.toutiao.com/account_login/", param, header);
-            System.out.println("res:" + new String(res.getBytes("GBK"), "UTF8"));
+            String res = HttpUtils2.httpPostParamRequest("https://sso.toutiao.com/account_login/", param, header);
 
             ObjectMapper mapper = new ObjectMapper();
             mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
@@ -90,14 +95,14 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 FateadmHttpUtil.HttpResp resp = fateadmUtil.Predict("30400", decoder.decodeBuffer(captcha));
                 param.put("captcha", resp.pred_resl);
                 orderId = resp.req_id;
-                res = HttpUtils.httpPostParamRequest("https://sso.toutiao.com/account_login/", param, header);
+                res = HttpUtils2.httpPostParamRequest("https://sso.toutiao.com/account_login/", param, header);
                 System.out.println("res:" + res);
                 jsonNode = mapper.readTree(res);
                 errorCode = jsonNode.get("error_code").asInt();
             }
             if (errorCode == 0) {
                 String csrftoken = "";
-                List<org.apache.http.cookie.Cookie> cookies = HttpUtils.cookieStore.getCookies();
+                List<org.apache.http.cookie.Cookie> cookies = HttpUtils2.cookieStore.getCookies();
                 for (org.apache.http.cookie.Cookie ck : cookies) {
                     Cookie cookie = new Cookie(ck.getName(), ck.getValue(), "." + ck.getDomain(), ck.getPath(), ck.getExpiryDate());
                     webDriver.manage().addCookie(cookie);
@@ -106,16 +111,16 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 webDriver.get("https://ad.oceanengine.com/pages/promotion.html#/ad");//登录成功 进入推广页面
                 Thread.sleep(3000);
                 webDriver.get("https://ad.oceanengine.com/pages/campaign/create.html");//创建广告组页面
-                Map<String, Object> param2 = new HashMap<String, Object>();
-                Map<String, Object> param3 = new HashMap<String, Object>();
+                Map<String, Object> campaignParam = new HashMap<>();
                 String uuid = UUID.randomUUID().toString();
-                param3.put("budget", 0);
-                param3.put("budget_mode", -1);
-                param2.put("campaign_id", "");
-                param2.put("campaign_name", uuid.substring(1, 7));
-                param2.put("landing_type", 3);
-                param2.put("campaign_type", 1);
-                param2.put("budget", param3);
+                campaignParam.put("campaign_id", "");
+                campaignParam.put("campaign_name", uuid.substring(1, 7));
+                campaignParam.put("landing_type", 3);
+                campaignParam.put("campaign_type", 1);
+                Map<String, Object> budgetMap = new HashMap<>();
+                budgetMap.put("budget", 0);
+                budgetMap.put("budget_mode", -1);
+                campaignParam.put("budget", budgetMap);
                 for (Cookie cookie : webDriver.manage().getCookies()) {
                     if ("csrftoken".equals(cookie.getName())) {
                         csrftoken = cookie.getValue();
@@ -124,8 +129,9 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                     ck.setDomain("ad.oceanengine.com");
                     ck.setExpiryDate(cookie.getExpiry());
                     ck.setPath(cookie.getPath());
-                    HttpUtils.cookieStore.addCookie(ck);
+                    HttpUtils2.cookieStore.addCookie(ck);
                 }
+
                 header.put("Accept", "application/json, text/javascript, */*; q=0.01");
                 header.put("Connection", "keep-alive");
                 header.put("Host", "ad.oceanengine.com");
@@ -134,96 +140,114 @@ public class CreateInternalServiceImpl implements ICreateInternalService {
                 header.put("X-CSRFToken", csrftoken);
                 header.put("X-Requested-With", "XMLHttpRequest");
                 header.put("Referer", "https://ad.oceanengine.com/pages/campaign/create.html");
-                res = HttpUtils.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", param2, header);// 创建广告组返回信息
+                res = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/campaign/create/", campaignParam, header);// 创建广告组返回信息
                 System.out.println(res);
-                JsonNode node = mapper.readTree(res);
-                String campaignId = node.get("data").get("campaign_id").asText();  //广告组id
-                String url2 = "https://ad.oceanengine.com/pages/ad/create.html?campaign_id=" + campaignId + "&landing_type=3&temp_id=ADvQb";
-                webDriver.get(url2);
-                header.put("Referer", url2);
-                for (Cookie cookie : webDriver.manage().getCookies()) {
-                    BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
-                    ck.setDomain("ad.oceanengine.com");
-                    ck.setExpiryDate(cookie.getExpiry());
-                    ck.setPath(cookie.getPath());
-                    HttpUtils.cookieStore.addCookie(ck);
-                }
-
-                Map<String, Object> param4 = new HashMap<String, Object>();
-                param4.put("location_type", 4);
-                param4.put("aweme_account_fans", 0);
-                String tokenStr = HttpUtils.httpPostRequest("https://ad.oceanengine.com/api/v1/hl/ad/audience/estimate/", param4, header);
-                JsonNode tokenNode = mapper.readTree(tokenStr);
-                Map<String, Object> param5 = new HashMap<String, Object>();
-                param5.put("name", requestJson.getString("templateName"));//模板名称
-                Integer deliveryRange = requestJson.getInteger("deliveryRange");
-                param5.put("delivery_range", deliveryRange);  //投放形式
-                if (deliveryRange == 2) {
-                    param5.put("union_video_type", requestJson.getInteger("deliveryForm")); //投放形式 1:激励视频 2:原生
-                }
-                param5.put("classify", requestJson.getString("adCategory")); //广告类别
-                param5.put("projectid", ""); //
-                Integer downloadType = requestJson.getInteger("downloadType");
-                param5.put("download_type", downloadType); //下载方式  1:下载包 2:h5
-                if (downloadType == 1) {
-                    param5.put("download_url", requestJson.getString("downloadUrl"));
-                }
-                if (downloadType == 2) {
-                    param5.put("external_url", requestJson.getString("externalUrl"));  // 落地页链接
-                }
-                param5.put("delivery_range", 1);  // 投放范围
-                param5.put("classify", 5);  //广告类别  5 内广
-                param5.put("projectid", "");
-                param5.put("localGeolocation", new ArrayList<String>());
-                param5.put("external_action", 4);
-                param5.put("open_url", ""); //  应用直达链接
-                param5.put("style_type", 0);
-                param5.put("location_type", 4); //受众位置类型
-                param5.put("hide_if_exists", 0); // 过滤已安装,当推广目标为安卓应用下载时可填,0表示不过滤,1表示过滤,默认为不过滤
-                param5.put("interest_tag_mode", 0); //兴趣分类
-                param5.put("token", tokenNode.get("data").get("token").asText());
-                param5.put("toutiao", 100000005);  //头条预估数据
-                param5.put("aweme", 150000005); //抖音预估数据
-                param5.put("video_app", 40000005);//西瓜预估数据
-                param5.put("hotsoon", 40000005); //火山预估数据
-                param5.put("aweme_account_fans", 0); //账号粉丝相似人群
-                param5.put("auto_extend_enabled", 0);// 智能放量????
-                param5.put("budget_mode", requestJson.getIntValue("budgetPriceMode"));  // 广告预算类型  0 日预算  1 总预算
-                param5.put("budget", requestJson.getIntValue("budgetPrice")); //广告预算
-                int scheduleType = requestJson.getIntValue("dateQuantum");
-                param5.put("schedule_type", scheduleType); //广告投放时间类型   默认1 1:不限  2:按时间???
-                if (scheduleType == 2) {
-                    param5.put("start_time", requestJson.getString("startDate")); //广告投放起始时间
-                    param5.put("end_time", requestJson.getString("endDate"));//广告投放结束时间
-                }
-                param5.put("week_schedule", new ArrayList<String>());  //投放时段
-                param5.put("week_time", new ArrayList<ArrayList<Integer>>());//投放时段
-                int pricing = requestJson.getIntValue("pricing");
-                param5.put("pricing", pricing); //计划出价类型  9 按展示付费  7 按点击付费 8 按转化付费
-                param5.put("cpa_phrase", 2); //出价为OCPC时,计划处于哪个阶段??
-                param5.put("is_union_slot", "");
-                param5.put("hide_if_converted", 1); //过滤已转化用户类型字段,只有转化为目标时可填 优化目标为转化才展示
-                param5.put("flow_control_mode", requestJson.getIntValue("flowControlMode")); //投放速度/投放方式使用字段
-                if (pricing == 9) {
-                    param5.put("cpa_bid", requestJson.getIntValue("convertPrice"));
-                } else {
-                    param5.put("bid", requestJson.getIntValue("convertPrice"));
+                Integer itratorNum = requestJson.getInteger("itratorNum");
+                if (null != itratorNum && itratorNum > 0) {
+                    //循环创建广告计划
+                    for (int i = 0; i < itratorNum; i++) {
+                        JsonNode node = mapper.readTree(res);
+                        String campaignId = node.get("data").get("campaign_id").asText();  //广告组id
+                        String url2 = "https://ad.oceanengine.com/pages/ad/create.html?campaign_id=" + campaignId + "&landing_type=3&temp_id=ADvQb";
+                        webDriver.get(url2);
+                        header.put("Referer", url2);
+                        for (Cookie cookie : webDriver.manage().getCookies()) {
+                            BasicClientCookie ck = new BasicClientCookie(cookie.getName(), cookie.getValue());
+                            ck.setDomain("ad.oceanengine.com");
+                            ck.setExpiryDate(cookie.getExpiry());
+                            ck.setPath(cookie.getPath());
+                            HttpUtils2.cookieStore.addCookie(ck);
+                        }
+                        Map<String, Object> audienceParam = new HashMap<>();
+                        audienceParam.put("location_type", 4);
+                        audienceParam.put("aweme_account_fans", 0);
+                        String tokenStr = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/api/v1/hl/ad/audience/estimate/", audienceParam, header);
+                        JsonNode tokenNode = mapper.readTree(tokenStr);
+                        Map<String, Object> planParam = new HashMap<>();
+                        planParam.put("name", requestJson.getString("templateName"));//模板名称
+                        Integer deliveryRange = requestJson.getInteger("deliveryRange");
+                        planParam.put("delivery_range", deliveryRange);  //投放形式
+                        if (deliveryRange == 2) {
+                            planParam.put("union_video_type", requestJson.getInteger("deliveryForm")); //投放形式 1:激励视频 2:原生
+                        }
+                        planParam.put("classify", requestJson.getString("adCategory")); //广告类别
+                        planParam.put("projectid", ""); //
+                        Integer downloadType = requestJson.getInteger("downloadType");
+                        planParam.put("download_type", downloadType); //下载方式  1:下载包 2:h5
+                        Long urlId = requestJson.getLong("urlId");
+                        BytedanceUrlInfo urlInfo = urlInfoMapper.selectById(urlId);
+                        if (downloadType == 1) {
+                            planParam.put("download_url", urlInfo.getUrl());
+                            planParam.put("package", urlInfo.getPackageName());
+                        }
+                        if (downloadType == 2) {
+                            planParam.put("external_url", urlInfo.getUrl());  // 落地页链接
+                        }
+                        planParam.put("delivery_range", 1);  // 投放范围
+                        planParam.put("classify", 5);  //广告类别  5 内广
+                        planParam.put("projectid", "");
+                        planParam.put("localGeolocation", new ArrayList<String>());
+                        planParam.put("external_action", 4);
+                        planParam.put("open_url", ""); //  应用直达链接
+                        planParam.put("style_type", 0);
+                        planParam.put("location_type", 4); //受众位置类型
+                        planParam.put("hide_if_exists", 0); // 过滤已安装,当推广目标为安卓应用下载时可填,0表示不过滤,1表示过滤,默认为不过滤
+                        planParam.put("interest_tag_mode", 0); //兴趣分类
+                        planParam.put("token", tokenNode.get("data").get("token").asText());
+                        planParam.put("toutiao", 100000005);  //头条预估数据
+                        planParam.put("aweme", 150000005); //抖音预估数据
+                        planParam.put("video_app", 40000005);//西瓜预估数据
+                        planParam.put("hotsoon", 40000005); //火山预估数据
+                        planParam.put("aweme_account_fans", 0); //账号粉丝相似人群
+                        planParam.put("auto_extend_enabled", 0);// 智能放量????
+                        planParam.put("budget_mode", requestJson.getIntValue("budgetPriceMode"));  // 广告预算类型  0 日预算  1 总预算
+                        planParam.put("budget", requestJson.getIntValue("budgetPrice")); //广告预算
+                        int scheduleType = requestJson.getIntValue("dateQuantum");
+                        planParam.put("schedule_type", scheduleType); //广告投放时间类型   默认1 1:不限  2:按时间???
+                        if (scheduleType == 2) {
+                            planParam.put("start_time", requestJson.getString("startDate")); //广告投放起始时间
+                            planParam.put("end_time", requestJson.getString("endDate"));//广告投放结束时间
+                        }
+                        planParam.put("week_schedule", new ArrayList<String>());  //投放时段
+                        planParam.put("week_time", new ArrayList<ArrayList<Integer>>());//投放时段
+                        int pricing = requestJson.getIntValue("pricing");
+                        planParam.put("pricing", pricing); //计划出价类型  9 按展示付费  7 按点击付费 8 按转化付费
+                        planParam.put("cpa_phrase", 2); //出价为OCPC时,计划处于哪个阶段??
+                        planParam.put("is_union_slot", "");
+                        planParam.put("hide_if_converted", 1); //过滤已转化用户类型字段,只有转化为目标时可填 优化目标为转化才展示
+                        planParam.put("flow_control_mode", requestJson.getIntValue("flowControlMode")); //投放速度/投放方式使用字段
+                        if (pricing == 9) {
+                            planParam.put("cpa_bid", requestJson.getIntValue("convertPrice"));
+                        } else {
+                            planParam.put("bid", requestJson.getIntValue("convertPrice"));
+                        }
+                        planParam.put("smart_bid_type", requestJson.getIntValue("bidType")); //自动出价类型,OCPM支持
+                        planParam.put("adjust_cpa", 0); //是否调整自动出价   允许值: "0", "1"  默认值: 0
+                        planParam.put("app_bid_ratio", new Object());
+                        planParam.put("name", "自动创建测试b" + i);  //广计划名称
+                        planParam.put("campaign_id", campaignId);
+                        String downLoadMode = requestJson.getString("downloadMode");
+                        planParam.put("app_type", 201); //app 类型 201 应用推广 安卓 201 应用推广 ios
+                        String createResult = HttpUtils2.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/", planParam, header);
+                        JSONObject result = JSONObject.parseObject(createResult);
+                        System.out.println(result.toJSONString());
+                        String status = result.getString("status");
+                        String msg = result.getString("msg");
+                        if (null != status && !status.equals("success")) {
+                            resultMap.put("code", -1);
+                            resultMap.put("message", msg);
+                            resultMap.put("success", false);
+                            return resultMap;
+                        }
+                    }
                 }
-                param5.put("package", requestJson.getString("packageName"));
-                param5.put("smart_bid_type", requestJson.getIntValue("bidType")); //自动出价类型,OCPM支持
-                param5.put("adjust_cpa", 0); //是否调整自动出价   允许值: "0", "1"  默认值: 0
-                param5.put("app_bid_ratio", new Object());
-                param5.put("name", "自动创建测试b");  //广计划名称
-                param5.put("campaign_id", campaignId);
-                param5.put("app_type", 201); //app 类型 201 应用推广 安卓 201 应用推广 ios
-                String createResult = HttpUtils.httpPostRequest("https://ad.oceanengine.com/overture/ad/create/", param5, header);
-                System.out.println(createResult);
             }
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
             webDriver.quit();
         }
-        return null;
+        ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS.getCode());
+        return resultMap;
     }
 }

+ 15 - 15
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/service/impl/ReportServiceImpl.java

@@ -246,8 +246,8 @@ public class ReportServiceImpl implements IReportService {
 
     public String getExcelDataPath(String date, Long accountId1, Long accountId4) throws Exception {
 
-        List<StatisticCampaignVo> statisticCampaign4Vos = statisticInfoMapper.getVoByParams(date, accountId4);
         List<StatisticCampaignVo> statisticCampaign1Vos = statisticInfoMapper.getVoByParams(date, accountId1);
+        List<StatisticCampaignVo> statisticCampaign4Vos = statisticInfoMapper.getVoByParams(date, accountId4);
 
         File f = new File(csvUploadPath + "template.xlsx");
         InputStream inputStream = new FileInputStream(f);
@@ -444,85 +444,85 @@ public class ReportServiceImpl implements IReportService {
                 if (null != vo.getRegistCreditNum() && !"".equals(vo.getRegistCreditNum())) {
                     cell.setCellValue(Integer.parseInt(vo.getRegistCreditNum()));
                 }
-            } else if (j == 25) {
+            } else if (j == 24) {
                 //注册成本
                 if (null != vo.getRegistPrice() && !"".equals(vo.getRegistPrice())) {
                     cell.setCellValue(Float.parseFloat(vo.getRegistPrice()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 26) {
+            } else if (j == 25) {
                 //完件成本
                 if (null != vo.getCompletePrice() && !"".equals(vo.getCompletePrice())) {
                     cell.setCellValue(Float.parseFloat(vo.getCompletePrice()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 27) {
+            } else if (j == 26) {
                 //授信成本
                 if (null != vo.getCreditPrice() && !"".equals(vo.getCreditPrice())) {
                     cell.setCellValue(Float.parseFloat(vo.getCreditPrice()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 28) {
+            } else if (j == 27) {
                 //当日注册且完件成本
                 if (null != vo.getRegistCompletePrice() && !"".equals(vo.getRegistCompletePrice())) {
                     cell.setCellValue(Float.parseFloat(vo.getRegistCompletePrice()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 29) {
+            } else if (j == 28) {
                 //当日注册且授信成本
                 if (null != vo.getRegistCreditPrice() && !"".equals(vo.getRegistCreditPrice())) {
                     cell.setCellValue(Float.parseFloat(vo.getRegistCreditPrice()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 30) {
+            } else if (j == 29) {
                 //点击注册率
                 if (null != vo.getClickRegistRate() && !"".equals(vo.getClickRegistRate())) {
                     cell.setCellValue(Float.parseFloat(vo.getClickRegistRate()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 31) {
+            } else if (j == 30) {
                 //行为注册率
                 if (null != vo.getActionRegistRate() && !"".equals(vo.getActionRegistRate())) {
                     cell.setCellValue(Float.parseFloat(vo.getActionRegistRate()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 32) {
+            } else if (j == 31) {
                 //完件率
                 if (null != vo.getCompleteRate() && !"".equals(vo.getCompleteRate())) {
                     cell.setCellValue(Float.parseFloat(vo.getCompleteRate()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 33) {
+            } else if (j == 32) {
                 //授信率
                 if (null != vo.getCreditRate() && !"".equals(vo.getCreditRate())) {
                     cell.setCellValue(Float.parseFloat(vo.getCreditRate()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 34) {
+            } else if (j == 33) {
                 //当日完件率
                 if (null != vo.getRegistCompleteRate() && !"".equals(vo.getRegistCompleteRate())) {
                     cell.setCellValue(Float.parseFloat(vo.getRegistCompleteRate()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 35) {
+            } else if (j == 34) {
                 //当日授信率
                 if (null != vo.getRegistCreditRate() && !"".equals(vo.getRegistCreditRate())) {
                     cell.setCellValue(Float.parseFloat(vo.getRegistCreditRate()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 36) {
+            } else if (j == 35) {
                 //当日完件/完件
                 if (null != vo.getCompleteRateDay() && !"".equals(vo.getCompleteRateDay())) {
                     cell.setCellValue(Float.parseFloat(vo.getCompleteRateDay()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 37) {
+            } else if (j == 36) {
                 //当日授信/授信
                 if (null != vo.getCreditRateDay() && !"".equals(vo.getCreditRateDay())) {
                     cell.setCellValue(Float.parseFloat(vo.getCreditRateDay()));
                     cell.setCellStyle(numbericCellStyle);
                 }
-            } else if (j == 38) {
+            } else if (j == 37) {
                 //当日授信/注册
                 if (null != vo.getCreditRegistRateDay() && !"".equals(vo.getCreditRegistRateDay())) {
                     cell.setCellValue(Float.parseFloat(vo.getCreditRegistRateDay()));

+ 59 - 0
jeecg-boot-module-system/src/test/java/org/jeecg/ChromeTest.java

@@ -0,0 +1,59 @@
+//package org.jeecg;
+//
+//import org.junit.AfterClass;
+//import org.junit.BeforeClass;
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.openqa.selenium.chrome.ChromeDriver;
+//import org.springframework.boot.test.context.SpringBootTest;
+//import org.springframework.test.context.junit4.SpringRunner;
+//
+//import java.util.concurrent.TimeUnit;
+//
+//@RunWith(SpringRunner.class)
+//@SpringBootTest
+//public class ChromeTest {
+//    private static ChromeDriver browser;
+//
+//    @BeforeClass
+//    public static void openBrowser() {
+//        System.setProperty("webdriver.chrome.driver","D:/chromedriver.exe");
+//        browser = new ChromeDriver();
+//        browser.manage().timeouts()
+//                .implicitlyWait(10, TimeUnit.SECONDS);
+//    }
+//
+//    @AfterClass
+//    public static void closeBrowser() {
+//        browser.quit();
+//    }
+//
+//    @Test
+//    public void addBookToEmptyList() throws InterruptedException {
+//        System.out.println("服务器端口:" + 3000);
+//        // 要测试的网址
+//        String baseUrl = "http://localhost:" + 3000 + "/TEST" ;
+//        browser.get(baseUrl);
+//        // 对网页表单元素进行赋值操作并提交表单
+//        assertEquals("You have no books in your book list",
+//                browser.findElementByTagName("div").getText());
+//        browser.findElementByName("title")
+//                .sendKeys("BOOK TITLE");
+//        browser.findElementByName("author")
+//                .sendKeys("BOOK AUTHOR");
+//        browser.findElementByName("isbn")
+//                .sendKeys("1234567890");
+//        browser.findElementByName("description")
+//                .sendKeys("DESCRIPTION");
+//        browser.findElementByTagName("form")
+//                .submit();
+//        // 测试运行结果是否符合预期
+//        WebElement dl =
+//                browser.findElementByCssSelector("dt.bookHeadline");
+//        assertEquals("BOOK TITLE by BOOK AUTHOR (ISBN: 1234567890)",
+//                dl.getText());
+//        WebElement dt =
+//                browser.findElementByCssSelector("dd.bookDescription");
+//        assertEquals("DESCRIPTION", dt.getText());
+//    }
+//}