64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package biz
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
"voucher/internal/biz/repo"
|
|
"voucher/internal/biz/thirdrepo"
|
|
"voucher/internal/biz/wechatrepo"
|
|
"voucher/internal/data"
|
|
"voucher/internal/pkg/lock"
|
|
)
|
|
|
|
type VoucherBiz struct {
|
|
rdb *data.Rdb
|
|
OrderRepo repo.OrderRepo
|
|
ThirdMQSend thirdrepo.ThirdMQSend
|
|
WechatCpnRepo wechatrepo.WechatCpnRepo
|
|
}
|
|
|
|
func NewVoucherBiz(
|
|
rdb *data.Rdb,
|
|
orderRepo repo.OrderRepo,
|
|
thirdMQSend thirdrepo.ThirdMQSend,
|
|
WechatCpnRepo wechatrepo.WechatCpnRepo,
|
|
) *VoucherBiz {
|
|
return &VoucherBiz{
|
|
rdb: rdb,
|
|
OrderRepo: orderRepo,
|
|
ThirdMQSend: thirdMQSend,
|
|
WechatCpnRepo: WechatCpnRepo,
|
|
}
|
|
}
|
|
|
|
func (v *VoucherBiz) OrderConsume(ctx context.Context, orderNo string) (err error) {
|
|
|
|
err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("order_consume_%s", orderNo), func(ctx context.Context) error {
|
|
|
|
return nil
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
func (v *VoucherBiz) QueryConsume(ctx context.Context, orderNo string) (err error) {
|
|
|
|
err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("query_consume_%s", orderNo), func(ctx context.Context) error {
|
|
|
|
return nil
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
func (v *VoucherBiz) NotifyConsume(ctx context.Context, orderNo string) (err error) {
|
|
|
|
err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("notify_consume_%s", orderNo), func(ctx context.Context) error {
|
|
|
|
return nil
|
|
})
|
|
|
|
return
|
|
}
|