预警13
This commit is contained in:
parent
144341501d
commit
760549de2a
|
|
@ -20,6 +20,7 @@ type ProductBo struct {
|
|||
AllBudget int64
|
||||
AvailableBudget int64
|
||||
WarningBudget int64
|
||||
WarningPerson string
|
||||
StartTime *time.Time
|
||||
EndTime *time.Time
|
||||
CreateTime *time.Time
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue