|
|
@@ -464,7 +464,11 @@ public class ConversionSyncService {
|
|
|
|
|
|
private CallbackDispatchResult sendCallback(CallbackTask task) {
|
|
|
if (task.isTencent()) {
|
|
|
- if (shouldDeductTencentCallback(task)) {
|
|
|
+ DeductionHandling handling = handleTencentDeduction(task);
|
|
|
+ if (handling == DeductionHandling.SKIP_DUPLICATE) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (handling == DeductionHandling.DEDUCT) {
|
|
|
MediaCallbackRecord deductedRecord = buildDeductedCallbackRecord(task);
|
|
|
return CallbackDispatchResult.tencent(task, deductedRecord);
|
|
|
}
|
|
|
@@ -617,21 +621,21 @@ public class ConversionSyncService {
|
|
|
conversionId);
|
|
|
}
|
|
|
|
|
|
- private boolean shouldDeductTencentCallback(CallbackTask task) {
|
|
|
+ private DeductionHandling handleTencentDeduction(CallbackTask task) {
|
|
|
if (!task.isTencent() || task.tencentBid == null) {
|
|
|
- return false;
|
|
|
+ return DeductionHandling.SEND;
|
|
|
}
|
|
|
int deductionRate = resolveDeductionRate(task.tencentBid);
|
|
|
if (task.payment.getAct() == 2001 || deductionRate <= 0) {
|
|
|
- return false;
|
|
|
+ return DeductionHandling.SEND;
|
|
|
}
|
|
|
if (!isNewTrackingLink(task.tencentBid)) {
|
|
|
- return false;
|
|
|
+ return DeductionHandling.SEND;
|
|
|
}
|
|
|
if (!hotStore.markConversionSeen(task.callbackKey)) {
|
|
|
- log.info("[ConversionSync] 腾讯转化已见过,跳过扣量计数 | callbackKey={} | qk={} | accountId={}",
|
|
|
+ log.info("[ConversionSync] 腾讯转化已见过,跳过后续发送 | callbackKey={} | qk={} | accountId={}",
|
|
|
task.callbackKey, task.payment.getQk(), safe(task.tencentBid.getAccountId()));
|
|
|
- return false;
|
|
|
+ return DeductionHandling.SKIP_DUPLICATE;
|
|
|
}
|
|
|
RedisHotStore.DeductionDecision decision = hotStore.evaluateDeduction(
|
|
|
task.tencentBid.getAccountId(),
|
|
|
@@ -645,7 +649,7 @@ public class ConversionSyncService {
|
|
|
task.payment.getQk(), task.payment.getAct(), safe(task.tencentBid.getAccountId()),
|
|
|
resolveTrackingVersion(task.tencentBid), deductionRate,
|
|
|
decision.getTotalSeen(), decision.getTotalDeducted(), task.callbackKey, deduct);
|
|
|
- return deduct;
|
|
|
+ return deduct ? DeductionHandling.DEDUCT : DeductionHandling.SEND;
|
|
|
}
|
|
|
|
|
|
private static boolean isNewTrackingLink(BidRecord bid) {
|
|
|
@@ -848,6 +852,12 @@ public class ConversionSyncService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private enum DeductionHandling {
|
|
|
+ SEND,
|
|
|
+ DEDUCT,
|
|
|
+ SKIP_DUPLICATE
|
|
|
+ }
|
|
|
+
|
|
|
public static class SyncResult {
|
|
|
public final AtomicInteger fetched = new AtomicInteger();
|
|
|
public final AtomicInteger matched = new AtomicInteger();
|