93 lines
2.4 KiB
Go
93 lines
2.4 KiB
Go
package biz
|
|
|
|
import (
|
|
"sync"
|
|
"voucher/internal/biz/cmb"
|
|
"voucher/internal/biz/mixrepos"
|
|
"voucher/internal/biz/repo"
|
|
"voucher/internal/biz/wechatrepo"
|
|
"voucher/internal/conf"
|
|
"voucher/internal/data"
|
|
)
|
|
|
|
type VoucherBiz struct {
|
|
bc *conf.Bootstrap
|
|
rdb *data.Rdb
|
|
Cmb *cmb.Cmb
|
|
ProductRepo repo.ProductRepo
|
|
OrderRepo repo.OrderRepo
|
|
OrderNotifyRepo repo.OrderNotifyRepo
|
|
WechatNotifyRegisterTagRepo repo.WechatNotifyRegisterTagRepo
|
|
MqSendMixRepo mixrepos.MQSendMixRepo
|
|
GenerateMixRepo mixrepos.GenerateMixRepo
|
|
WechatCpnRepo wechatrepo.WechatCpnRepo
|
|
DingMixRepo mixrepos.DingMixRepo
|
|
CmbMixRepo mixrepos.CmbMixRepo
|
|
SmsMixRepo mixrepos.SmsMixRepo
|
|
|
|
mu sync.RWMutex
|
|
queryMap map[string]bool
|
|
}
|
|
|
|
func NewVoucherBiz(
|
|
bc *conf.Bootstrap,
|
|
rdb *data.Rdb,
|
|
Cmb *cmb.Cmb,
|
|
ProductRepo repo.ProductRepo,
|
|
OrderRepo repo.OrderRepo,
|
|
OrderNotifyRepo repo.OrderNotifyRepo,
|
|
WechatNotifyRegisterTagRepo repo.WechatNotifyRegisterTagRepo,
|
|
MqSendMixRepo mixrepos.MQSendMixRepo,
|
|
GenerateMixRepo mixrepos.GenerateMixRepo,
|
|
WechatCpnRepo wechatrepo.WechatCpnRepo,
|
|
DingMixRepo mixrepos.DingMixRepo,
|
|
CmbMixRepo mixrepos.CmbMixRepo,
|
|
SmsMixRepo mixrepos.SmsMixRepo,
|
|
) *VoucherBiz {
|
|
return &VoucherBiz{
|
|
bc: bc,
|
|
rdb: rdb,
|
|
Cmb: Cmb,
|
|
ProductRepo: ProductRepo,
|
|
OrderRepo: OrderRepo,
|
|
OrderNotifyRepo: OrderNotifyRepo,
|
|
WechatNotifyRegisterTagRepo: WechatNotifyRegisterTagRepo,
|
|
MqSendMixRepo: MqSendMixRepo,
|
|
GenerateMixRepo: GenerateMixRepo,
|
|
WechatCpnRepo: WechatCpnRepo,
|
|
DingMixRepo: DingMixRepo,
|
|
CmbMixRepo: CmbMixRepo,
|
|
SmsMixRepo: SmsMixRepo,
|
|
|
|
queryMap: make(map[string]bool),
|
|
}
|
|
}
|
|
|
|
func (this *VoucherBiz) Get(uid string) bool {
|
|
this.mu.Lock()
|
|
defer this.mu.Unlock()
|
|
|
|
if _, ok := this.queryMap[uid]; ok {
|
|
return ok
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func (this *VoucherBiz) Add(uid string) {
|
|
this.mu.Lock()
|
|
defer this.mu.Unlock()
|
|
|
|
this.queryMap[uid] = true
|
|
}
|
|
|
|
func (this *VoucherBiz) Remove(uid string) {
|
|
|
|
this.mu.Lock()
|
|
defer this.mu.Unlock()
|
|
|
|
if _, ok := this.queryMap[uid]; ok {
|
|
delete(this.queryMap, uid)
|
|
}
|
|
}
|