From 760549de2a13122b8e7811e305d428bd356019ca Mon Sep 17 00:00:00 2001 From: ziming Date: Tue, 1 Jul 2025 18:25:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=AD=A613?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/biz/bo/product_bo.go | 1 + internal/biz/voucher.go | 3 +++ internal/biz/warning_budget.go | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/biz/bo/product_bo.go b/internal/biz/bo/product_bo.go index c778fcb..1cd43eb 100644 --- a/internal/biz/bo/product_bo.go +++ b/internal/biz/bo/product_bo.go @@ -20,6 +20,7 @@ type ProductBo struct { AllBudget int64 AvailableBudget int64 WarningBudget int64 + WarningPerson string StartTime *time.Time EndTime *time.Time CreateTime *time.Time diff --git a/internal/biz/voucher.go b/internal/biz/voucher.go index 7c92587..cf56f38 100644 --- a/internal/biz/voucher.go +++ b/internal/biz/voucher.go @@ -23,6 +23,7 @@ type VoucherBiz struct { WechatCpnRepo wechatrepo.WechatCpnRepo DingMixRepo mixrepos.DingMixRepo CmbMixRepo mixrepos.CmbMixRepo + SmsMixRepo mixrepos.SmsMixRepo mu sync.RWMutex queryMap map[string]bool @@ -41,6 +42,7 @@ func NewVoucherBiz( WechatCpnRepo wechatrepo.WechatCpnRepo, DingMixRepo mixrepos.DingMixRepo, CmbMixRepo mixrepos.CmbMixRepo, + SmsMixRepo mixrepos.SmsMixRepo, ) *VoucherBiz { return &VoucherBiz{ bc: bc, @@ -55,6 +57,7 @@ func NewVoucherBiz( WechatCpnRepo: WechatCpnRepo, DingMixRepo: DingMixRepo, CmbMixRepo: CmbMixRepo, + SmsMixRepo: SmsMixRepo, queryMap: make(map[string]bool), } diff --git a/internal/biz/warning_budget.go b/internal/biz/warning_budget.go index 008076c..7d50373 100644 --- a/internal/biz/warning_budget.go +++ b/internal/biz/warning_budget.go @@ -2,6 +2,7 @@ package biz import ( "context" + "encoding/json" "fmt" "github.com/go-kratos/kratos/v2/log" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" @@ -147,14 +148,21 @@ func (this *VoucherBiz) Calculate(ctx context.Context, product *bo.ProductBo, wx func (this *VoucherBiz) WarningSend(ctx context.Context, product *bo.ProductBo, w *do.WxResp) error { - err := this.DingMixRepo.SendMarkdownMessage(ctx, "券预算不足", formatAsCard(product, w)) - if err != nil { + var warningPerson []*do.WarningPerson + if err := json.Unmarshal([]byte(product.WarningPerson), &warningPerson); err != nil { return err } - buildTemplateParams(product, w) + if err := this.DingMixRepo.SendMarkdownMessage(ctx, "券预算不足", formatAsCard(product, w)); err != nil { + return err + } - return nil + var mobileList []string + for _, person := range warningPerson { + mobileList = append(mobileList, person.Mobile) + } + + return this.SmsMixRepo.Send(ctx, mobileList, buildTemplateParams(product, w)) } func buildTemplateParams(product *bo.ProductBo, req *do.WxResp) map[string]string {