yumeng 1 kuukausi sitten
vanhempi
commit
bfd3c3d1ce

+ 37 - 4
src/main/java/cn/com/ctop/track/controller/JingDongCpaController.java

@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
@@ -96,7 +97,7 @@ public class JingDongCpaController {
                     String eventType = redisUtil.get(eventAccountKey);
                     if (eventType.equals("1")) { // 转化类型为订单提交  订单提交回传订单提交 其他不关注
                         if (jd_event_type.equals("4")) {
-                            String returnedKey = "returned_" + 14 + "_"+requestId;
+                            String returnedKey = "returned_" + 14 + "_" + requestId;
                             String isReturned = redisUtil.get(returnedKey);
                             if (!Check.isNull(isReturned)) {
                                 log.info("此点击链接已回传,clickId:{}", requestId);
@@ -131,7 +132,7 @@ public class JingDongCpaController {
 
                     } else if (eventType.equals("2")) {
                         if (jd_event_type.equals("1")) {
-                            String returnedKey = "returned_" + 2 + "_"+requestId;
+                            String returnedKey = "returned_" + 2 + "_" + requestId;
                             String isReturned = redisUtil.get(returnedKey);
                             if (!Check.isNull(isReturned)) {
                                 log.info("此点击链接已回传,clickId:{}", requestId);
@@ -160,7 +161,7 @@ public class JingDongCpaController {
 
                             redisUtil.add(returnedKey, 1, 2, TimeUnit.DAYS);
                         } else if (jd_event_type.equals("4")) {
-                            String returnedKey = "returned_" + 1 + "_"+requestId;
+                            String returnedKey = "returned_" + 1 + "_" + requestId;
                             String isReturned = redisUtil.get(returnedKey);
                             if (!Check.isNull(isReturned)) {
                                 log.info("此点击链接已回传,clickId:{}", requestId);
@@ -200,7 +201,7 @@ public class JingDongCpaController {
 
                     });
                     callback += stringBuffer.toString();
-                    String result = HttpUtils.KuaiShouttpGetRequestNew(callback,null);
+                    String result = HttpUtils.KuaiShouttpGetRequestNew(callback, null);
                     log.info("信息上报媒体返回结果:{}", result.toString());
                 }
             }
@@ -218,6 +219,38 @@ public class JingDongCpaController {
     }
 
 
+    @GetMapping(value = "/addAccountEvent")
+    @ResponseBody
+    public JSONObject addAccountEvent(String accountId, String type) {
+        JSONObject returnJson = new JSONObject();
+
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户ID不能为空");
+            }
+
+            if (Check.isNull(type)) {
+                throw new Exception("type不能为空");
+            }
+            Integer typeInt = Integer.valueOf(type);
+            if (typeInt == 0 || typeInt > 2) {
+                throw new Exception("type值只能是1或2");
+            }
+            String key = "event_" + accountId;
+            redisUtil.add(key, type);
+            returnJson.put("code", 200);
+            returnJson.put("message", "添加成功");
+            returnJson.put("accountId", accountId);
+            returnJson.put("type", type);
+
+        } catch (Exception e) {
+            returnJson.put("code", 500);
+            returnJson.put("message", e.getMessage());
+        }
+        return returnJson;
+    }
+
+
     public static void main(String[] args) {
         Integer i = 0;
         i = i + 1;