Update:增加过滤

This commit is contained in:
jiaji.H 2026-06-11 09:48:43 +08:00
parent ae3d62ff24
commit 4b7c56d1b6

View File

@ -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`")