From 8a19225eb523f4423117e5bf86dca91d2820f291 Mon Sep 17 00:00:00 2001 From: cjy Date: Tue, 9 Jun 2026 12:26:24 +0800 Subject: [PATCH] =?UTF-8?q?Update=EF=BC=9A=E4=BB=BB=E5=8A=A1=E5=8F=B0?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E8=BF=87=E6=BB=A4=E6=8C=89=20contract=5Ftpl?= =?UTF-8?q?=5Ftype=20=E6=8B=86=E5=88=86=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 先用后付分支:仅取 contract_tpl_type=3 的增值先用后付订单 - 普通任务分支:追加 contract_tpl_type=2 的套餐先用后付主订单 - latestOrderFilter 同步纳入两类订单的「较新订单」比较 - 修正 06fb278 中「套餐先用后付主订单被错算成先用后付任务」的问题 --- internal/dao/taskDao.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/internal/dao/taskDao.go b/internal/dao/taskDao.go index 001d0d5..1f1bdba 100644 --- a/internal/dao/taskDao.go +++ b/internal/dao/taskDao.go @@ -67,17 +67,26 @@ func normalizeBundleTaskType(bundleTaskType int) int { func taskStatsQueryOptions(bundleTaskType int) (int, int, string, string) { taskType := normalizeBundleTaskType(bundleTaskType) if taskType == model.BundleTaskTypePayLater { - return taskType, model.BillingTypeBNPL, "bor.order_mode = 2 AND bor.pay_later_status IN (1, 2)", "" + // 先用后付任务分支:只取 contract_tpl_type=3 的增值先用后付订单(只有视频额度) + // 套餐先用后付主订单 (contract_tpl_type=2) 归到普通任务分支 + return taskType, model.BillingTypeBNPL, "bor.order_mode = 2 AND bor.contract_tpl_type = 3 AND bor.pay_later_status IN (1, 2)", "" } - return taskType, model.BillingTypeNormal, "bor.status = 2 AND IFNULL(bor.order_mode, 1) = 1", ` + // 普通任务分支:order_mode=1 的普通套餐 + contract_tpl_type=2 的套餐先用后付主订单 + // 套餐先用后付主订单用 BNPL 语义 (pay_later_status IN (1,2)) 判定活跃 + return taskType, model.BillingTypeNormal, ` + ((bor.status = 2 AND IFNULL(bor.order_mode, 1) = 1) + OR (bor.contract_tpl_type = 2 AND bor.pay_later_status IN (1, 2))) + `, ` AND NOT EXISTS ( SELECT 1 FROM bundle_order_records bor2 WHERE bor2.customer_id = bor.customer_id AND bor2.deleted_at IS NULL AND bor2.customer_id IS NOT NULL - AND bor2.status = 2 - AND IFNULL(bor2.order_mode, 1) = 1 + AND ( + (bor2.status = 2 AND IFNULL(bor2.order_mode, 1) = 1) + OR (bor2.contract_tpl_type = 2 AND bor2.pay_later_status IN (1, 2)) + ) AND (bor2.created_at > bor.created_at OR (bor2.created_at = bor.created_at AND bor2.id > bor.id)) )` }