38 lines
812 B
Go
38 lines
812 B
Go
package biz
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
"voucher/internal/biz/bo"
|
|
"voucher/internal/pkg/lock"
|
|
)
|
|
|
|
func (v *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) (orderNo string, err error) {
|
|
|
|
err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("cmb_order_%s", req.OutBizNo), func(ctx context.Context) error {
|
|
|
|
if orderNo, err = v.Cmb.Order(ctx, req); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
func (v *VoucherBiz) CmbProductQuery(ctx context.Context, productNo string) (reps *bo.OrderCreateRepBo, err error) {
|
|
|
|
err = lock.NewMutex(v.rdb.Rdb, time.Second*30).Lock(ctx, fmt.Sprintf("cmb_query_%s", productNo), func(ctx context.Context) error {
|
|
|
|
if reps, err = v.Cmb.Query(ctx, productNo); err != nil {
|
|
return err
|
|
}
|
|
|
|
return nil
|
|
})
|
|
|
|
return
|
|
}
|