|
@@ -16,28 +16,34 @@
|
|
|
<result property="responseBody" column="response_body"/>
|
|
<result property="responseBody" column="response_body"/>
|
|
|
<result property="errorMessage" column="error_message"/>
|
|
<result property="errorMessage" column="error_message"/>
|
|
|
<result property="requestBody" column="request_body"/>
|
|
<result property="requestBody" column="request_body"/>
|
|
|
|
|
+ <result property="dispatchStatus" column="dispatch_status"/>
|
|
|
|
|
+ <result property="trackingVersion" column="tracking_version"/>
|
|
|
<result property="createdAt" column="created_at"/>
|
|
<result property="createdAt" column="created_at"/>
|
|
|
</resultMap>
|
|
</resultMap>
|
|
|
|
|
|
|
|
<insert id="insert">
|
|
<insert id="insert">
|
|
|
INSERT INTO tencent_media_callbacks (
|
|
INSERT INTO tencent_media_callbacks (
|
|
|
dedupe_key, media, qk, callback_url, event_type, event_time_ms, purchase,
|
|
dedupe_key, media, qk, callback_url, event_type, event_time_ms, purchase,
|
|
|
- status, ok, attempt, response_body, error_message, request_body, created_at
|
|
|
|
|
|
|
+ status, ok, attempt, response_body, error_message, request_body, dispatch_status, tracking_version, created_at
|
|
|
) VALUES (
|
|
) VALUES (
|
|
|
#{dedupeKey}, #{media}, #{qk}, #{callbackUrl}, #{eventType}, #{eventTimeMs},
|
|
#{dedupeKey}, #{media}, #{qk}, #{callbackUrl}, #{eventType}, #{eventTimeMs},
|
|
|
#{purchase}, #{status}, #{ok}, #{attempt}, #{responseBody}, #{errorMessage},
|
|
#{purchase}, #{status}, #{ok}, #{attempt}, #{responseBody}, #{errorMessage},
|
|
|
- #{requestBody}, #{createdAt}
|
|
|
|
|
|
|
+ #{requestBody}, #{dispatchStatus}, #{trackingVersion}, #{createdAt}
|
|
|
)
|
|
)
|
|
|
</insert>
|
|
</insert>
|
|
|
|
|
|
|
|
<select id="countSuccessfulByDedupeKey" resultType="int">
|
|
<select id="countSuccessfulByDedupeKey" resultType="int">
|
|
|
- SELECT COUNT(1) FROM tencent_media_callbacks WHERE dedupe_key = #{dedupeKey} AND ok = 1 LIMIT 1
|
|
|
|
|
|
|
+ SELECT COUNT(1)
|
|
|
|
|
+ FROM tencent_media_callbacks
|
|
|
|
|
+ WHERE dedupe_key = #{dedupeKey}
|
|
|
|
|
+ AND (ok = 1 OR dispatch_status = 'DEDUCTED')
|
|
|
|
|
+ LIMIT 1
|
|
|
</select>
|
|
</select>
|
|
|
|
|
|
|
|
<select id="countSuccessfulForEvent" resultType="int">
|
|
<select id="countSuccessfulForEvent" resultType="int">
|
|
|
SELECT COUNT(1)
|
|
SELECT COUNT(1)
|
|
|
FROM tencent_media_callbacks
|
|
FROM tencent_media_callbacks
|
|
|
- WHERE ok = 1
|
|
|
|
|
|
|
+ WHERE (ok = 1 OR dispatch_status = 'DEDUCTED')
|
|
|
AND (
|
|
AND (
|
|
|
dedupe_key = #{dedupeKey}
|
|
dedupe_key = #{dedupeKey}
|
|
|
OR (dedupe_key = #{legacyDedupeKey} AND event_type = #{eventType})
|
|
OR (dedupe_key = #{legacyDedupeKey} AND event_type = #{eventType})
|
|
@@ -48,7 +54,7 @@
|
|
|
<select id="selectSuccessfulDedupeKeys" resultType="string">
|
|
<select id="selectSuccessfulDedupeKeys" resultType="string">
|
|
|
SELECT DISTINCT dedupe_key
|
|
SELECT DISTINCT dedupe_key
|
|
|
FROM tencent_media_callbacks
|
|
FROM tencent_media_callbacks
|
|
|
- WHERE ok = 1
|
|
|
|
|
|
|
+ WHERE (ok = 1 OR dispatch_status = 'DEDUCTED')
|
|
|
AND dedupe_key IN
|
|
AND dedupe_key IN
|
|
|
<foreach collection="dedupeKeys" item="dedupeKey" open="(" separator="," close=")">
|
|
<foreach collection="dedupeKeys" item="dedupeKey" open="(" separator="," close=")">
|
|
|
#{dedupeKey}
|
|
#{dedupeKey}
|
|
@@ -58,7 +64,7 @@
|
|
|
<select id="selectSuccessfulKeysWithLegacy" resultType="string">
|
|
<select id="selectSuccessfulKeysWithLegacy" resultType="string">
|
|
|
SELECT DISTINCT dedupe_key
|
|
SELECT DISTINCT dedupe_key
|
|
|
FROM tencent_media_callbacks
|
|
FROM tencent_media_callbacks
|
|
|
- WHERE ok = 1
|
|
|
|
|
|
|
+ WHERE (ok = 1 OR dispatch_status = 'DEDUCTED')
|
|
|
AND dedupe_key IN
|
|
AND dedupe_key IN
|
|
|
<foreach collection="dedupeKeys" item="dedupeKey" open="(" separator="," close=")">
|
|
<foreach collection="dedupeKeys" item="dedupeKey" open="(" separator="," close=")">
|
|
|
#{dedupeKey}
|
|
#{dedupeKey}
|
|
@@ -66,7 +72,7 @@
|
|
|
UNION
|
|
UNION
|
|
|
SELECT DISTINCT dedupe_key
|
|
SELECT DISTINCT dedupe_key
|
|
|
FROM tencent_media_callbacks
|
|
FROM tencent_media_callbacks
|
|
|
- WHERE ok = 1
|
|
|
|
|
|
|
+ WHERE (ok = 1 OR dispatch_status = 'DEDUCTED')
|
|
|
AND event_type IN
|
|
AND event_type IN
|
|
|
<foreach collection="eventTypes" item="eventType" open="(" separator="," close=")">
|
|
<foreach collection="eventTypes" item="eventType" open="(" separator="," close=")">
|
|
|
#{eventType}
|
|
#{eventType}
|
|
@@ -80,13 +86,13 @@
|
|
|
<insert id="batchInsert">
|
|
<insert id="batchInsert">
|
|
|
INSERT INTO tencent_media_callbacks (
|
|
INSERT INTO tencent_media_callbacks (
|
|
|
dedupe_key, media, qk, callback_url, event_type, event_time_ms, purchase,
|
|
dedupe_key, media, qk, callback_url, event_type, event_time_ms, purchase,
|
|
|
- status, ok, attempt, response_body, error_message, request_body, created_at
|
|
|
|
|
|
|
+ status, ok, attempt, response_body, error_message, request_body, dispatch_status, tracking_version, created_at
|
|
|
) VALUES
|
|
) VALUES
|
|
|
<foreach collection="records" item="r" separator=",">
|
|
<foreach collection="records" item="r" separator=",">
|
|
|
(
|
|
(
|
|
|
#{r.dedupeKey}, #{r.media}, #{r.qk}, #{r.callbackUrl}, #{r.eventType}, #{r.eventTimeMs},
|
|
#{r.dedupeKey}, #{r.media}, #{r.qk}, #{r.callbackUrl}, #{r.eventType}, #{r.eventTimeMs},
|
|
|
#{r.purchase}, #{r.status}, #{r.ok}, #{r.attempt}, #{r.responseBody}, #{r.errorMessage},
|
|
#{r.purchase}, #{r.status}, #{r.ok}, #{r.attempt}, #{r.responseBody}, #{r.errorMessage},
|
|
|
- #{r.requestBody}, #{r.createdAtTs}
|
|
|
|
|
|
|
+ #{r.requestBody}, #{r.dispatchStatus}, #{r.trackingVersion}, #{r.createdAtTs}
|
|
|
)
|
|
)
|
|
|
</foreach>
|
|
</foreach>
|
|
|
</insert>
|
|
</insert>
|
|
@@ -94,7 +100,7 @@
|
|
|
<select id="selectPendingCallbacks" resultMap="mediaCallbackResultMap">
|
|
<select id="selectPendingCallbacks" resultMap="mediaCallbackResultMap">
|
|
|
SELECT m.dedupe_key, m.media, m.qk, m.callback_url, m.event_type, m.event_time_ms,
|
|
SELECT m.dedupe_key, m.media, m.qk, m.callback_url, m.event_type, m.event_time_ms,
|
|
|
m.purchase, m.status, m.ok AS ok_val, m.attempt, m.response_body, m.error_message,
|
|
m.purchase, m.status, m.ok AS ok_val, m.attempt, m.response_body, m.error_message,
|
|
|
- m.request_body, m.created_at
|
|
|
|
|
|
|
+ m.request_body, m.dispatch_status, m.tracking_version, m.created_at
|
|
|
FROM tencent_media_callbacks m
|
|
FROM tencent_media_callbacks m
|
|
|
JOIN (
|
|
JOIN (
|
|
|
SELECT dedupe_key, MAX(id) AS id
|
|
SELECT dedupe_key, MAX(id) AS id
|
|
@@ -103,9 +109,11 @@
|
|
|
GROUP BY dedupe_key
|
|
GROUP BY dedupe_key
|
|
|
) latest ON latest.id = m.id
|
|
) latest ON latest.id = m.id
|
|
|
WHERE m.media = #{media} AND m.ok = 0
|
|
WHERE m.media = #{media} AND m.ok = 0
|
|
|
|
|
+ AND COALESCE(m.dispatch_status, 'SENT') != 'DEDUCTED'
|
|
|
AND NOT EXISTS (
|
|
AND NOT EXISTS (
|
|
|
SELECT 1 FROM tencent_media_callbacks ok_cb
|
|
SELECT 1 FROM tencent_media_callbacks ok_cb
|
|
|
- WHERE ok_cb.dedupe_key = m.dedupe_key AND ok_cb.ok = 1
|
|
|
|
|
|
|
+ WHERE ok_cb.dedupe_key = m.dedupe_key
|
|
|
|
|
+ AND (ok_cb.ok = 1 OR ok_cb.dispatch_status = 'DEDUCTED')
|
|
|
)
|
|
)
|
|
|
ORDER BY m.created_at ASC
|
|
ORDER BY m.created_at ASC
|
|
|
LIMIT #{limit}
|
|
LIMIT #{limit}
|