|
|
@@ -10,10 +10,16 @@ import com.tzld.piaoquan.risk.control.service.qywx.Constant;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
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 javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.Enumeration;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
@RestController
|
|
|
@RequestMapping("/qw")
|
|
|
public class QwCallbackController {
|
|
|
@@ -22,6 +28,46 @@ public class QwCallbackController {
|
|
|
private QywxUserDataService userDataService;
|
|
|
@Autowired
|
|
|
private RiskUserOperateService riskUserOperateService;
|
|
|
+
|
|
|
+ @UnAuth
|
|
|
+ @GetMapping("/callback")
|
|
|
+ public void onAdCallback(HttpServletRequest request) {
|
|
|
+ // 1. 获取查询字符串
|
|
|
+ String queryString = request.getQueryString();
|
|
|
+ LOGGER.info("Received ad callback query string: {}, timestamp:{}", queryString, System.currentTimeMillis());
|
|
|
+
|
|
|
+ // 2. 解析查询参数
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ Enumeration<String> parameterNames = request.getParameterNames();
|
|
|
+ while (parameterNames.hasMoreElements()) {
|
|
|
+ String paramName = parameterNames.nextElement();
|
|
|
+ String paramValue = request.getParameter(paramName);
|
|
|
+ params.put(paramName, paramValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. 转换为 JSON 字符串用于日志输出
|
|
|
+ String paramsJson = JSON.toJSONString(params);
|
|
|
+ LOGGER.info("Parsed ad callback params: {}", paramsJson);
|
|
|
+
|
|
|
+ // 4. 提取具体参数
|
|
|
+ String trace_id = params.get("trace_id");
|
|
|
+ String wechat_open_id = params.get("wechat_open_id");
|
|
|
+ String adgroup_id = params.get("adgroup_id");
|
|
|
+ String act_time = params.get("act_time");
|
|
|
+ String wechat_account_id = params.get("wechat_account_id");
|
|
|
+ String advertiser_id = params.get("advertiser_id");
|
|
|
+ String device_os_type = params.get("device_os_type");
|
|
|
+ String shared_ad = params.get("shared_ad");
|
|
|
+ String dynamic_creative_id = params.get("dynamic_creative_id");
|
|
|
+ String callback = params.get("callback");
|
|
|
+
|
|
|
+ // 5. 详细日志输出
|
|
|
+ LOGGER.info("Ad callback details - trace_id: {}, wechat_open_id: {}, adgroup_id: {}, act_time: {}, wechat_account_id: {}, advertiser_id: {}, device_os_type: {}, shared_ad: {}, dynamic_creative_id: {}, callback: {}",
|
|
|
+ trace_id, wechat_open_id, adgroup_id, act_time, wechat_account_id, advertiser_id, device_os_type, shared_ad, dynamic_creative_id, callback);
|
|
|
+
|
|
|
+ // TODO: 处理广告回调逻辑
|
|
|
+ }
|
|
|
+
|
|
|
@UnAuth
|
|
|
@PostMapping("/callback")
|
|
|
public void onMessage(@RequestBody String callbackData) {
|