From 4b7c56d1b6069323d4394ea4b4330af0e4e7ded1 Mon Sep 17 00:00:00 2001 From: "jiaji.H" Date: Thu, 11 Jun 2026 09:48:43 +0800 Subject: [PATCH] =?UTF-8?q?Update=EF=BC=9A=E5=A2=9E=E5=8A=A0=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/bundleMetrics.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/internal/dao/bundleMetrics.go b/internal/dao/bundleMetrics.go index e48bc67..7b58500 100644 --- a/internal/dao/bundleMetrics.go +++ b/internal/dao/bundleMetrics.go @@ -996,7 +996,9 @@ func manualIncreaseBundleBalance(startTime string, endTime string, bundleUUID st // 通过 order_uuid 联表 bundle_order_records 获取 bundle_uuid Joins("left join bundle_order_records bor ON bor.uuid = bb.order_uuid and bor.deleted_at is null and bor.status = 2"). // 支持 bundle_uuid 过滤 - Where("bor.bundle_uuid = ?", bundleUUID) + Where("bor.bundle_uuid = ?", bundleUUID). + // 只统计订单类型为基础套餐的数据,避免统计到先用后付订单 + Where("bor.order_type = 1") } if err = quary.Scan(&data).Error; err != nil { return @@ -1031,7 +1033,7 @@ func balanceInfoWithShop(startMonth string, endMonth string, startTime string, e bb.monthly_bundle_limit_expired_competitive_number ) AS competitive `). // 不限制类型的总数 + 限制不过期类型的当月可用 + 限制过期类型的当月可用 = 新增待上传数量 - Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid"). + Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid and bor.order_type = ?", model.BundleTypeBasic). Joins(`INNER JOIN ( SELECT order_uuid, MIN(created_at) AS min_created_at FROM bundle_balance @@ -1040,6 +1042,7 @@ func balanceInfoWithShop(startMonth string, endMonth string, startTime string, e ) AS bb_min ON bb.order_uuid = bb_min.order_uuid AND bb.created_at = bb_min.min_created_at`). Where("bor.deleted_at is null and bor.status=2"). Where("bb.month = DATE_FORMAT(bb.start_at, '%Y-%m')"). + Where("bor.order_type = ?", model.BundleTypeBasic). Where("bb.deleted_at IS NULL") if bundleUUID != "" { subQuery = subQuery.Where("bor.bundle_uuid = ?", bundleUUID) @@ -1092,7 +1095,7 @@ func IncreasealanceInfoWithShop(startMonth string, endMonth string, startTime st bb.monthly_increase_limit_expired_competitive_number ) AS competitive `). // 不限制类型的总数 + 限制不过期类型的当月可用 + 限制过期类型的当月可用 = 新增待上传数量 - Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid"). + Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid and bor.order_type = ?", model.BundleTypeBasic). Joins(`INNER JOIN ( SELECT order_uuid, MIN(created_at) AS min_created_at FROM bundle_balance @@ -1183,7 +1186,7 @@ func getBundleBalanceInfo(month string, bundleUUID string, endTime string) (data bb.monthly_bundle_limit_competitive_consumption_number ) AS competitive `). // 不限制类型的总数 + 限制不过期类型的当月可用 + 限制过期类型的当月可用 + 限制不过期类型的总共已用 + 限制过期类型的总共已用 + 已过期的数量 = 总发放数 - Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid"). + Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid and bor.order_type = ?", model.BundleTypeBasic). Where("bor.deleted_at is null and bor.status=2"). Joins(`INNER JOIN ( SELECT @@ -1269,7 +1272,7 @@ func getIncreaseBalanceInfo(month string, bundleUUID string, endTime string) (da bb.monthly_increase_limit_competitive_consumption_number ) AS competitive `). // 不限制类型的总数 + 限制不过期类型的当月可用 + 限制过期类型的当月可用 + 限制不过期类型的总共已用 + 限制过期类型的总共已用 + 已过期的数量 = 总发放数 - Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid"). + Joins("LEFT JOIN bundle_order_records bor ON bor.uuid = bb.order_uuid and bor.order_type = ?", model.BundleTypeBasic). Joins(`INNER JOIN ( SELECT bb_inner.user_id, @@ -1458,7 +1461,7 @@ func MetricsBundlePurchaseExport(req *bundle.MetricsBundlePurchaseExportReq) (*b where a1.deleted_at is null and a1.status = 2 and a1.total_amount > 300 and a2.deleted_at is null group by a1.order_no ) t4 on t1.order_no = t4.order_no - where t1.deleted_at is null and t1.status = 2 and t1.total_amount > 300 + where t1.deleted_at is null and t1.status = 2 and t1.total_amount > 300 and t1.order_type = 1 order by t2.sub_num asc`, "`micro-account`.`user`", "`micro-account`.`real_name`")