This commit is contained in:
ziming 2025-07-01 18:25:35 +08:00
parent 144341501d
commit 760549de2a
3 changed files with 16 additions and 4 deletions

View File

@ -20,6 +20,7 @@ type ProductBo struct {
AllBudget int64 AllBudget int64
AvailableBudget int64 AvailableBudget int64
WarningBudget int64 WarningBudget int64
WarningPerson string
StartTime *time.Time StartTime *time.Time
EndTime *time.Time EndTime *time.Time
CreateTime *time.Time CreateTime *time.Time

View File

@ -23,6 +23,7 @@ type VoucherBiz struct {
WechatCpnRepo wechatrepo.WechatCpnRepo WechatCpnRepo wechatrepo.WechatCpnRepo
DingMixRepo mixrepos.DingMixRepo DingMixRepo mixrepos.DingMixRepo
CmbMixRepo mixrepos.CmbMixRepo CmbMixRepo mixrepos.CmbMixRepo
SmsMixRepo mixrepos.SmsMixRepo
mu sync.RWMutex mu sync.RWMutex
queryMap map[string]bool queryMap map[string]bool
@ -41,6 +42,7 @@ func NewVoucherBiz(
WechatCpnRepo wechatrepo.WechatCpnRepo, WechatCpnRepo wechatrepo.WechatCpnRepo,
DingMixRepo mixrepos.DingMixRepo, DingMixRepo mixrepos.DingMixRepo,
CmbMixRepo mixrepos.CmbMixRepo, CmbMixRepo mixrepos.CmbMixRepo,
SmsMixRepo mixrepos.SmsMixRepo,
) *VoucherBiz { ) *VoucherBiz {
return &VoucherBiz{ return &VoucherBiz{
bc: bc, bc: bc,
@ -55,6 +57,7 @@ func NewVoucherBiz(
WechatCpnRepo: WechatCpnRepo, WechatCpnRepo: WechatCpnRepo,
DingMixRepo: DingMixRepo, DingMixRepo: DingMixRepo,
CmbMixRepo: CmbMixRepo, CmbMixRepo: CmbMixRepo,
SmsMixRepo: SmsMixRepo,
queryMap: make(map[string]bool), queryMap: make(map[string]bool),
} }

View File

@ -2,6 +2,7 @@ package biz
import ( import (
"context" "context"
"encoding/json"
"fmt" "fmt"
"github.com/go-kratos/kratos/v2/log" "github.com/go-kratos/kratos/v2/log"
"github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "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 { func (this *VoucherBiz) WarningSend(ctx context.Context, product *bo.ProductBo, w *do.WxResp) error {
err := this.DingMixRepo.SendMarkdownMessage(ctx, "券预算不足", formatAsCard(product, w)) var warningPerson []*do.WarningPerson
if err != nil { if err := json.Unmarshal([]byte(product.WarningPerson), &warningPerson); err != nil {
return err 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 { func buildTemplateParams(product *bo.ProductBo, req *do.WxResp) map[string]string {