From 45385724d1e5fa847ffa004a6b10321838deecf2 Mon Sep 17 00:00:00 2001 From: "jiaji.H" Date: Wed, 10 Jun 2026 17:17:00 +0800 Subject: [PATCH] =?UTF-8?q?Update:=E6=9B=B4=E6=96=B0=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/bundleExtend.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/dao/bundleExtend.go b/internal/dao/bundleExtend.go index 2f1ea56..a67bdb9 100644 --- a/internal/dao/bundleExtend.go +++ b/internal/dao/bundleExtend.go @@ -73,6 +73,7 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun Joins(`INNER JOIN ( SELECT customer_id, MAX(created_at) AS max_created_time FROM bundle_order_records + WHERE order_type = 1 AND deleted_at is NULL GROUP BY customer_id ) bor2 ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time`) session := app.ModuleClients.BundleDB.Table("`micro-account`.`user` AS u").Unscoped(). @@ -90,7 +91,8 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun Where("rn.name IS NOT NULL"). Where("u.deleted_at = 0"). Where("bor.deleted_at IS NULL"). - Where("bor.status = 2"). + Where("((bor.order_mode = 2 AND bor.pay_later_status > 0 ) OR (bor.order_mode = 1 AND bor.status = 2 ))"). + Where("bb.bundle_type = ?", model.BundleTypeBasic). Order("bor.expiration_time desc") if req.UserName != "" { if utils.IsPhoneNumber(req.UserName) { @@ -120,9 +122,6 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun if req.Bought == 1 { session = session.Where("bb.user_id IS NULL") } - if req.BundleType != 0 { - session = session.Where("bb.bundle_type = ?", req.BundleType) - } t := time.Now() if req.StatusType != 0 { if req.ExpiredTimeStart > time.Now().UnixMilli() { @@ -187,7 +186,7 @@ func GetPayLaterBundleBalanceList(req *bundle.GetPayLaterBundleBalanceListReq) ( Joins(`INNER JOIN ( SELECT customer_id, MAX(created_at) AS max_created_time FROM bundle_order_records - WHERE order_type = 2 AND deleted_at is NULL + WHERE order_type = 2 AND deleted_at is NULL AND bor.pay_later_status > 0 GROUP BY customer_id ) bor2 ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time`) @@ -242,11 +241,11 @@ func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (data mod subQuery := app.ModuleClients.BundleDB.Table("bundle_order_records as bor1"). Select("bor1.*"). Joins(`INNER JOIN ( - SELECT customer_id, MAX(created_at) AS max_created_time + SELECT customer_id FROM bundle_order_records - WHERE status = 2 AND deleted_at is NULL + WHERE ((order_mode = 2 AND pay_later_status > 0 ) OR (order_mode = 1 AND status = 2 )) AND deleted_at is NULL GROUP BY customer_id - ) bor2 ON bor1.customer_id = bor2.customer_id AND bor1.created_at = bor2.max_created_time`) + ) bor2 ON bor1.customer_id = bor2.customer_id`) session := app.ModuleClients.BundleDB.Table("`micro-account`.`user` AS u").Unscoped(). Select(`bb.*, bor.bundle_name, bor.status,bor.amount AS payment_amount,bor.amount_type AS payment_type,bor.customer_num, bor.uuid as order_uuid, rn.name as user_name,bc.activate,bor.created_at as pay_time, @@ -259,9 +258,10 @@ func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (data mod Where("u.deleted_at = 0"). Where("u.id = ?", req.UserId). Where("bb.month = ?", time.Now().Format("2006-01")). + Where("bb.expired_at >= ?", time.Now()). Order("bor.expiration_time desc") if req.OrderUUID != "" { - session = session.Where("bb.order_uuid = ?", req.OrderUUID) + session = session.Where("bor.uuid = ?", req.OrderUUID).Where("bb.order_uuid = ?", req.OrderUUID) } err = session.First(&data).Error return