package service import ( "fmt" "github.com/go-kratos/kratos/v2/transport/http" "github.com/robfig/cron" http2 "net/http" "strconv" v1 "voucher/api/v1" "voucher/internal/biz" "voucher/internal/biz/mixrepos" "voucher/internal/biz/wechatrepo" "voucher/internal/conf" ) var _ v1.CmbHTTPServer = (*CmbService)(nil) type CmbService struct { bc *conf.Bootstrap cron *cron.Cron VoucherBiz *biz.VoucherBiz CmbMixRepo mixrepos.CmbMixRepo WechatCpnRepo wechatrepo.WechatCpnRepo } func NewCmbService( bc *conf.Bootstrap, cron *cron.Cron, VoucherBiz *biz.VoucherBiz, CmbMixRepo mixrepos.CmbMixRepo, WechatCpnRepo wechatrepo.WechatCpnRepo, ) *CmbService { return &CmbService{ bc: bc, cron: cron, VoucherBiz: VoucherBiz, CmbMixRepo: CmbMixRepo, WechatCpnRepo: WechatCpnRepo, } } func (this *CmbService) NotifyRetry(ctx http.Context) error { id := ctx.Vars().Get("id") if id == "" { return fmt.Errorf("id is empty") } orderNotifyId, err := strconv.ParseUint(id, 10, 64) if err != nil { return err } return this.VoucherBiz.PushNotifyRetryDelayMQ(ctx, 1, orderNotifyId) } func (this *CmbService) QueryOrder(ctx http.Context) error { orderNo := ctx.Vars().Get("order_no") if orderNo == "" { return fmt.Errorf("orderNo is empty") } str, err := this.VoucherBiz.QueryOrder(ctx, orderNo) if err != nil { return err } return ctx.JSON(http2.StatusOK, map[string]interface{}{ "data": str, }) } func (this *CmbService) RegisterTag(ctx http.Context) error { productNo := ctx.Vars().Get("product_no") if productNo == "" { return fmt.Errorf("productNo is empty") } return ctx.JSON(http2.StatusOK, map[string]interface{}{ "data": this.VoucherBiz.RegisterTag(ctx, productNo), }) }