From f55af5f719626daaaa9f93cfb4717b6aa5f642c0 Mon Sep 17 00:00:00 2001 From: lzh <1625167628@qq.com> Date: Tue, 24 Jun 2025 16:29:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=BE=85=E7=A1=AE=E8=AE=A4?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/bundleExtend.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/dao/bundleExtend.go b/internal/dao/bundleExtend.go index e34abc4..e9cc192 100644 --- a/internal/dao/bundleExtend.go +++ b/internal/dao/bundleExtend.go @@ -97,6 +97,9 @@ func GetBundleExtendRecordList(req *bundle.BundleExtendRecordsListRequest) (data } func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.BundleBalancePo, total int64, err error) { + subQuery := app.ModuleClients.BundleDB.Table("bundle_order_records"). + Select("customer_id, MAX(created_at) AS max_created_time"). + Group("customer_id") session := app.ModuleClients.BundleDB.Table("`micro-account`.`user` AS u"). Select(` bb.*, @@ -111,7 +114,8 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (data []model.Bun Joins("LEFT JOIN fiee_bundle.bundle_balance AS bb on u.id = bb.user_id"). Joins("LEFT JOIN `micro-account`.`real_name` rn on u.real_name_id = rn.id"). Joins("LEFT JOIN bundle_order_records bor on bor.uuid = bb.order_uuid"). - Where("bor.deleted_at IS NULL and rn.name IS NOT NULL and u.deleted_at = 0") + Joins("INNER JOIN (?) AS t ON bor.customer_id = t.customer_id AND bor.created_at = t.max_created_time", subQuery). + Where("rn.name IS NOT NULL and u.deleted_at = 0") if req.UserName != "" { if utils.IsPhoneNumber(req.UserName) { session = session.Where("u.tel_num = ?", req.UserName) @@ -286,7 +290,7 @@ func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (data []model.CastWor session := app.ModuleClients.BundleDB. Table("cast_work_log AS cwl"). Joins("INNER JOIN (?) AS t ON cwl.work_uuid = t.work_uuid AND cwl.update_time = t.max_update_time", subQuery). - Where("artist_uuid = ?", req.ArtistUuid) + Where("artist_uuid = ?", req.ArtistUuid).Where("work_status in ?", []int{4, 5, 6, 7}) err = session.Count(&total).Error if err != nil { return