Pārlūkot izejas kodu

快手-广告组创建表单转化

yumeng 5 gadi atpakaļ
vecāks
revīzija
eb68ab09d5

+ 2 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/kuaishou/controller/KuaiShouConversionTypesController.java

@@ -66,7 +66,8 @@ public class KuaiShouConversionTypesController {
         }
         Map<String, Object> resultMap = kuaishouInterfaceService.getDeepConversionInfos(accountId, token.getAccessToken());
         if ((Integer) resultMap.get("code") == 0) {
-            result.setResult(resultMap.get("isActivate"));
+            result.setResult(resultMap);
+            System.err.println(result);
         }
         result.setSuccess(true);
 

+ 22 - 13
jeecg-boot-module-system/src/main/java/org/jeecg/modules/kuaishou/service/impl/KuaishouInterfaceServiceImpl.java

@@ -16,6 +16,7 @@ import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.type.TypeFactory;
 import constant.KuaishouInterfaceConstant;
+import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.http.ParseException;
 import org.jeecg.common.util.LoadFileUtil;
 import org.jeecg.modules.kuaishou.entity.*;
@@ -37,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
@@ -754,7 +756,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             logger.info(resultJson.toJSONString());
             if (!Check.isNullMap(resultJson)) {
                 Integer code = resultJson.getInteger("code");
-                boolean isActivate = false;
+                Integer is_activate = null;
+                Integer is_form_submit = null;
                 if (code == 0) {
                     Map<String, Object> deleteMap = new HashMap<>();
                     deleteMap.put("account_id", advertiserId);
@@ -764,12 +767,12 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                     if (!Check.isNullMap(dataJson)) {
                         KuaiShouConversionInfos conversionInfos = new KuaiShouConversionInfos();
                         conversionInfos.setAccountId(advertiserId);
-                        Integer is_activate = dataJson.getInteger("is_activate");
-                        if (is_activate == 1) {
-                            isActivate = true;
-                        }
+                        is_activate = dataJson.getInteger("is_activate");
+                        is_form_submit = dataJson.getInteger("is_form_submit");
+
+
                         conversionInfos.setIsActivate(is_activate);
-                        conversionInfos.setIsFormSubmit(dataJson.getInteger("is_form_submit"));
+                        conversionInfos.setIsFormSubmit(is_form_submit);
                         conversionInfosMapper.insert(conversionInfos);
                         JSONArray ConversionTypeArr = dataJson.getJSONArray("deep_conversion_types");
                         if (!Check.isNull(ConversionTypeArr)) {
@@ -788,7 +791,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
 
                     resultMap.put("code", 0);
                     resultMap.put("success", true);
-                    resultMap.put("isActivate", isActivate);
+                    resultMap.put("isActivate", is_activate);
+                    resultMap.put("isFormSubmit", is_form_submit);
 
                 } else {
                     logger.error("获取可选的深度转化类型返回异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
@@ -1016,14 +1020,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                                 videoGet.setCoverUrl(dataJson.getString("cover_url"));
                                 videoGetMapper.insert(videoGet);
                             }
-
                         }
-
                     }
-
                 } else {
                     logger.error("获取广告视频失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
-
                 }
 
             } else {
@@ -1054,12 +1054,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
             JSONObject param = new JSONObject();
             param.put("advertiser_id", advertiserId);
             param.put("image_token", image_token);
-
             Map<String, String> headers = new HashMap<String, String>();
             headers.put("Access-Token", accessToken);
             headers.put("Content-Type", " application/json");
             String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
-            System.err.println(result);
             JSONObject resultJson = JSONObject.parseObject(result);
             if (!Check.isNull(resultJson)) {
                 Integer code = resultJson.getInteger("code");
@@ -1546,5 +1544,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
         return null;
     }
 
+    public static void main(String[] args) throws IOException {
+        String path = "https://ctop-media.oss-cn-beijing.aliyuncs.com/06.13-%E5%8A%A8%E7%94%BB-%E5%A5%B3%E6%9C%8B%E5%8F%8B%E8%B7%9F%E6%88%91%E5%88%86%E6%89%8B-1566461277270.mp4";
+        String localUrl = LoadFileUtil.downLoadFromUrl(path, "D:\\file\\video");
+
+        try {
+            String s = DigestUtils.md5Hex(new FileInputStream(localUrl));
+            System.err.println(s);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
 
 }