diff --git a/configs/config.yaml b/configs/config.yaml index ffd5222..984ed0f 100644 --- a/configs/config.yaml +++ b/configs/config.yaml @@ -66,6 +66,7 @@ cmb: cmbKeyAlias: "SM2_CMBLIFE" orgNo: "LANSEXIONGDI" # 发码机构号,固定值,掌上生活优惠券系统提供 notifyUrl: "https://sandbox.cdcc.cmbchina.com/AccessGateway/transIn/updateCodeStatus.json" # 招行测试回调地址 + multiNotifyUrl: "https://sandbox.cdcc.cmbchina.com/AccessGateway/transIn/updateCodeStatus.json" # 招行测试回调地址 noticeStartDays: 7 noticeEndDays: 1 diff --git a/gorm.sh b/gorm.sh index 52d91e3..5777d2c 100755 --- a/gorm.sh +++ b/gorm.sh @@ -6,7 +6,7 @@ # 3. 在指定目录下创建对应表的CRUD操作代码文件,定义针对该表的常见增删改查以及列表查询、按字段查询等操作方法。 # 设置数据库连接信息,注意密码部分如果包含特殊字符可能需要进行转义处理,这里示例中未做额外处理,需根据实际情况检查 -dsn="root:lansexiongdi6,@tcp(47.97.27.195:3306)/voucher?parseTime=True&loc=Local" +dsn="root:lsxddb123.@tcp(47.108.53.72:3306)/voucher?parseTime=True&loc=Local" # 获取当前脚本所在的绝对路径,即使脚本被在不同目录下调用也能正确定位相关文件和目录 SHELL_FOLDER=$(cd "$(dirname "\$0")" || exit; pwd) echo "$SHELL_FOLDER" diff --git a/internal/biz/bo/wechat_voucher_bo.go b/internal/biz/bo/wechat_notify_bo.go similarity index 60% rename from internal/biz/bo/wechat_voucher_bo.go rename to internal/biz/bo/wechat_notify_bo.go index 6c99585..b8238b8 100644 --- a/internal/biz/bo/wechat_voucher_bo.go +++ b/internal/biz/bo/wechat_notify_bo.go @@ -1,12 +1,18 @@ package bo -import "voucher/internal/biz/vo" +import ( + "encoding/json" + "fmt" + "time" + "voucher/internal/biz/vo" +) // ConsumeInformation 定义消费信息结构体 type ConsumeInformation struct { - ConsumeTime string `json:"consume_time"` - ConsumeMchid string `json:"consume_mchid"` - TransactionID string `json:"transaction_id"` + ConsumeTime time.Time `json:"consume_time"` // 核销时间 + ConsumeMchid string `json:"consume_mchid"` // 核销商户号 + TransactionID string `json:"transaction_id"` // 微信支付交易单号 + ConsumeAmount int `json:"consume_amount"` // 核销金额(单位:分) } // PlainText 定义明文数据结构体 @@ -17,11 +23,12 @@ type PlainText struct { CouponName string `json:"coupon_name"` Description string `json:"description"` Status vo.WechatVoucherStatus `json:"status"` - CreateTime string `json:"create_time"` + CreateTime time.Time `json:"create_time"` CouponType string `json:"coupon_type"` NoCash bool `json:"no_cash"` Singleitem bool `json:"singleitem"` - ConsumeInformation ConsumeInformation `json:"consume_information,omitempty"` + BusinessType string `json:"business_type"` // 业务类型 + ConsumeInformation *ConsumeInformation `json:"consume_information,omitempty"` } type WechatVoucherNotifyBo struct { @@ -34,3 +41,13 @@ type WechatVoucherNotifyBo struct { AssociatedData string `json:"associated_data"` PlainText PlainText `json:"plain_text"` } + +func (d *WechatVoucherNotifyBo) Str() (string, error) { + + b, err := json.Marshal(d) + if err != nil { + return "", fmt.Errorf("json marshal original_data error: %v", err) + } + + return string(b), nil +} diff --git a/internal/biz/multi.go b/internal/biz/multi.go new file mode 100644 index 0000000..7fef2f0 --- /dev/null +++ b/internal/biz/multi.go @@ -0,0 +1,258 @@ +package biz + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "github.com/go-kratos/kratos/v2/log" + "gorm.io/gorm" + v1 "voucher/api/v1" + "voucher/internal/biz/bo" + "voucher/internal/biz/cmb" + "voucher/internal/biz/mixrepos" + "voucher/internal/biz/repo" + "voucher/internal/biz/vo" + "voucher/internal/conf" + "voucher/internal/data" + "voucher/internal/pkg/lock" +) + +type MultiBiz struct { + bc *conf.Bootstrap + rdb *data.Rdb + Cmb *cmb.Cmb + ProductRepo repo.ProductRepo + OrderRepo repo.OrderRepo + MultiNotifyDataRepo repo.MultiNotifyDataRepo + MultiNotifyLogRepo repo.MultiNotifyLogRepo + CmbMixRepo mixrepos.CmbMixRepo +} + +func NewMultiBiz( + bc *conf.Bootstrap, + rdb *data.Rdb, + cmb *cmb.Cmb, + productRepo repo.ProductRepo, + orderRepo repo.OrderRepo, + multiNotifyDataRepo repo.MultiNotifyDataRepo, + multiNotifyLogRepo repo.MultiNotifyLogRepo, + cmbMixRepo mixrepos.CmbMixRepo, +) *MultiBiz { + return &MultiBiz{ + bc: bc, + rdb: rdb, + Cmb: cmb, + ProductRepo: productRepo, + OrderRepo: orderRepo, + MultiNotifyDataRepo: multiNotifyDataRepo, + MultiNotifyLogRepo: multiNotifyLogRepo, + CmbMixRepo: cmbMixRepo, + } +} + +func (biz *MultiBiz) Notify(ctx context.Context, source string, req *bo.WechatVoucherNotifyBo) error { + + cl := vo.MultiNotifyLockKey.BuildCache([]string{ + source, + req.PlainText.StockCreatorMchid, + req.PlainText.StockID, + req.PlainText.CouponID, + }) + + return lock.NewMutex(biz.rdb.Rdb, cl.TTL).Lock(ctx, cl.Key, func(ctx context.Context) error { + + order, err := biz.order(ctx, req) + if err != nil { + log.Errorf("[%s] multi notify error: %v,req:%+v", source, err, req) + return err + } + + if err = biz.Run(ctx, source, req, order); err != nil { + log.Errorf("[%s] multi notify error: %v,req:%+v", source, err, req) + return err + } + + return nil + }) + +} + +func (biz *MultiBiz) order(ctx context.Context, req *bo.WechatVoucherNotifyBo) (*bo.OrderBo, error) { + + order, err := biz.OrderRepo.GetByCouponId(ctx, req.PlainText.StockCreatorMchid, req.PlainText.StockID, req.PlainText.CouponID) + if err != nil { + return nil, fmt.Errorf("订单查询错误 error: %v", err) + } + + return order, nil +} + +func (biz *MultiBiz) Run(ctx context.Context, source string, req *bo.WechatVoucherNotifyBo, order *bo.OrderBo) error { + + if order.ActivityId == "" { + return fmt.Errorf("批次活动ID为空,不是多笔立减金,请检查") + } + + mnd, err := biz.MultiNotifyDataRepo.GetByNotifyID(ctx, req.ID) + if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) { + return fmt.Errorf("查询通知数据错误 error: %v", err) + } + + if mnd != nil { + if mnd.NoticeNum > 0 { + log.Warnf("[%s] multi notify log already exists,req:%+v", source, req) + return nil + } + } else { + mnd, err = biz.mndCreate(ctx, source, req, order) + if err != nil { + return fmt.Errorf("创建通知数据错误 error: %v", err) + } + } + + nl, err := biz.nlCreate(ctx, req, mnd, order) + if err != nil { + return fmt.Errorf("创建通知日志错误 error: %v", err) + } + + return biz.Request(ctx, mnd, nl) +} + +func (biz *MultiBiz) mndCreate(ctx context.Context, source string, req *bo.WechatVoucherNotifyBo, order *bo.OrderBo) (*bo.MultiNotifyDataBo, error) { + + originalData, err := req.Str() + if err != nil { + return nil, fmt.Errorf("通知数据 json str 错误 error: %v", err) + } + + return biz.MultiNotifyDataRepo.Create(ctx, &bo.MultiNotifyDataBo{ + Source: source, + NotifyID: req.ID, + OrderNo: order.OrderNo, + OutBizNo: order.OutBizNo, + CouponID: req.PlainText.CouponID, + StockID: req.PlainText.StockID, + ConsumeAmount: int32(req.PlainText.ConsumeInformation.ConsumeAmount), + ConsumeTime: &req.PlainText.ConsumeInformation.ConsumeTime, + EventType: req.EventType, + OriginalData: originalData, + }) +} + +func (biz *MultiBiz) nlCreate(ctx context.Context, req *bo.WechatVoucherNotifyBo, mnd *bo.MultiNotifyDataBo, order *bo.OrderBo) (*bo.MultiNotifyLogBo, error) { + + nl := &bo.MultiNotifyLogBo{ + MultiNotifyDataID: mnd.ID, + OrderNo: mnd.OrderNo, + OutBizNo: mnd.OutBizNo, + CouponID: mnd.CouponID, + ActivityNo: order.ProductNo, + StockID: mnd.StockID, + EventType: mnd.EventType, + Status: req.PlainText.Status.GetValue(), + ConsumeAmount: mnd.ConsumeAmount, + ConsumeTime: mnd.ConsumeTime, + TransactionID: req.PlainText.ConsumeInformation.TransactionID, + RequestURL: order.NotifyUrl, + RequestStatus: vo.MultiNotifyLogStatusWait.GetValue(), + OrderCreateTime: order.CreateTime, + CouponCreateTime: &req.PlainText.CreateTime, + } + request, err := biz.GetRequest(ctx, nl) + if err != nil { + return nil, err + } + b, _ := json.Marshal(request) + nl.Request = string(b) + + return biz.MultiNotifyLogRepo.Create(ctx, nl) +} + +func (biz *MultiBiz) bizContent(nl *bo.MultiNotifyLogBo) (string, error) { + + req := &v1.CmbNotifyRequest{ // 待确定 + Ticket: nl.OrderNo, + TransDate: "", // 格式yyyy-mm-dd hh:mm:ss.sss + OrgNo: biz.bc.Cmb.OrgNo, + //Attach: nl.Attach, + Ext: "", + } + + bizJsonBytes, err := json.Marshal(req) + if err != nil { + return "", err + } + + return string(bizJsonBytes), nil +} + +func (biz *MultiBiz) GetRequest(ctx context.Context, nl *bo.MultiNotifyLogBo) (*v1.CmbRequest, error) { + + bizContent, err := biz.bizContent(nl) + if err != nil { + return nil, err + } + + request, err := biz.CmbMixRepo.GetRequest(ctx, &bo.CmbRequestBo{ + FuncName: vo.CmbNotifyFuncName, // 待确定 + BizContent: bizContent, + }) + if err != nil { + return nil, err + } + + return request, nil +} + +func (biz *MultiBiz) Request(ctx context.Context, mmd *bo.MultiNotifyDataBo, nl *bo.MultiNotifyLogBo) error { + + if nl.RequestURL == "" { + return biz.notifyFail(ctx, nl, "回调通知招行地址为空") + } + + request, err := biz.GetRequest(ctx, nl) + if err != nil { + return err + } + + reply, err := biz.CmbMixRepo.Request(ctx, request, nl.RequestURL) + if err != nil { + if err2 := biz.notifyFail(ctx, nl, err.Error()); err2 != nil { + return err2 + } + return err + } + + if err = biz.CmbMixRepo.VerifyResponse(ctx, reply); err != nil { + errMsg := fmt.Sprintf("回调通知招行返回验证结果发生错误,rep:%+v error:%s", reply, err.Error()) + if err2 := biz.notifyFail(ctx, nl, errMsg); err2 != nil { + return err2 + } + return err + } + + return biz.notifySuccess(ctx, mmd, nl, reply) +} + +func (biz *MultiBiz) notifyFail(ctx context.Context, nl *bo.MultiNotifyLogBo, remark string) error { + return biz.MultiNotifyLogRepo.Fail(ctx, nl.ID, remark) +} + +func (biz *MultiBiz) notifySuccess(ctx context.Context, mmd *bo.MultiNotifyDataBo, nl *bo.MultiNotifyLogBo, reply *v1.CmbReply) error { + + response, err := json.Marshal(reply) + if err != nil { + return err + } + + if err = biz.MultiNotifyLogRepo.Success(ctx, nl.ID, string(response)); err != nil { + return err + } + + if err = biz.MultiNotifyDataRepo.AddNoticeNum(ctx, mmd.ID); err != nil { + return err + } + + return nil +} diff --git a/internal/biz/order.go b/internal/biz/order.go index 4ef70cc..c00dda2 100644 --- a/internal/biz/order.go +++ b/internal/biz/order.go @@ -105,6 +105,10 @@ func (this *VoucherBiz) create(ctx context.Context, req *bo.OrderCreateReqBo, pr ActivityId: product.ActivityId, // 多笔立减活动 } + if product.ActivityId != "" { + o.NotifyUrl = this.bc.Cmb.MultiNotifyUrl + } + return this.OrderRepo.Create(ctx, o) } diff --git a/internal/biz/provider_set.go b/internal/biz/provider_set.go index f9f9c14..1b2e794 100644 --- a/internal/biz/provider_set.go +++ b/internal/biz/provider_set.go @@ -5,4 +5,4 @@ import ( ) // ProviderSetBiz is biz providers. -var ProviderSetBiz = wire.NewSet(NewVoucherBiz) +var ProviderSetBiz = wire.NewSet(NewVoucherBiz, NewMultiBiz) diff --git a/internal/biz/vo/cache.go b/internal/biz/vo/cache.go index 0650a04..23f5ff7 100644 --- a/internal/biz/vo/cache.go +++ b/internal/biz/vo/cache.go @@ -29,6 +29,10 @@ const ( ProductQueryLockKey CacheKey = "product_query_lock" ) +const ( + MultiNotifyLockKey CacheKey = "multi_notify_lock_key" +) + var ( WarningBudgetCron CacheKey = "warning_budget_cron" WarningBudgetSendIncr CacheKey = "warning_budget_incr" @@ -51,6 +55,8 @@ var CacheKeyMap = map[CacheKey]time.Duration{ WarningBudgetSendIncr: 3 * time.Hour, WarningBudgetCron: 5 * time.Minute, + + MultiNotifyLockKey: 30 * time.Second, } type Cache struct { diff --git a/internal/biz/vo/multi_notify_log_status.go b/internal/biz/vo/multi_notify_log_status.go new file mode 100644 index 0000000..362998d --- /dev/null +++ b/internal/biz/vo/multi_notify_log_status.go @@ -0,0 +1,38 @@ +package vo + +type MultiNotifyLogStatus int32 + +const ( + MultiNotifyLogStatusWait MultiNotifyLogStatus = iota + 1 + MultiNotifyLogStatusSuccess + MultiNotifyLogStatusFail +) + +var MultiNotifyLogStatusMap = map[MultiNotifyLogStatus]string{ + MultiNotifyLogStatusWait: "待请求", + MultiNotifyLogStatusSuccess: "请求成功", + MultiNotifyLogStatusFail: "请求失败", +} + +func (s MultiNotifyLogStatus) GetText() string { + if t, ok := MultiNotifyLogStatusMap[s]; ok { + return t + } + return "未知请求状态" +} + +func (s MultiNotifyLogStatus) GetValue() int32 { + return int32(s) +} + +func (s MultiNotifyLogStatus) IsWait() bool { + return s == MultiNotifyLogStatusWait +} + +func (s MultiNotifyLogStatus) IsSuccess() bool { + return s == MultiNotifyLogStatusSuccess +} + +func (s MultiNotifyLogStatus) IsFail() bool { + return s == MultiNotifyLogStatusFail +} diff --git a/internal/biz/voucher.go b/internal/biz/voucher.go index e21e639..9e743be 100644 --- a/internal/biz/voucher.go +++ b/internal/biz/voucher.go @@ -26,6 +26,7 @@ type VoucherBiz struct { DingMixRepo mixrepos.DingMixRepo CmbMixRepo mixrepos.CmbMixRepo SmsMixRepo mixrepos.SmsMixRepo + MultiBiz *MultiBiz mu sync.RWMutex queryMap map[string]bool @@ -47,6 +48,7 @@ func NewVoucherBiz( DingMixRepo mixrepos.DingMixRepo, CmbMixRepo mixrepos.CmbMixRepo, SmsMixRepo mixrepos.SmsMixRepo, + MultiBiz *MultiBiz, ) *VoucherBiz { return &VoucherBiz{ bc: bc, @@ -64,6 +66,7 @@ func NewVoucherBiz( DingMixRepo: DingMixRepo, CmbMixRepo: CmbMixRepo, SmsMixRepo: SmsMixRepo, + MultiBiz: MultiBiz, queryMap: make(map[string]bool), } diff --git a/internal/biz/wechat_notify.go b/internal/biz/wechat_notify.go index 32d8bf4..c939be8 100644 --- a/internal/biz/wechat_notify.go +++ b/internal/biz/wechat_notify.go @@ -22,6 +22,10 @@ func (this *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, re return err } + if order.ActivityId != "" { + return this.MultiBiz.Run(ctx, "lsxd_"+order.MerchantNo, req, order) + } + if req.PlainText.Status.IsSended() { return this.available(ctx, order) diff --git a/internal/conf/conf.pb.go b/internal/conf/conf.pb.go index 10176f4..5b9b766 100644 --- a/internal/conf/conf.pb.go +++ b/internal/conf/conf.pb.go @@ -486,6 +486,7 @@ type Cmb struct { CmbKeyAlias string `protobuf:"bytes,8,opt,name=cmbKeyAlias,proto3" json:"cmbKeyAlias,omitempty"` OrgNo string `protobuf:"bytes,9,opt,name=orgNo,proto3" json:"orgNo,omitempty"` NotifyUrl string `protobuf:"bytes,10,opt,name=notifyUrl,proto3" json:"notifyUrl,omitempty"` + MultiNotifyUrl string `protobuf:"bytes,13,opt,name=multiNotifyUrl,proto3" json:"multiNotifyUrl,omitempty"` NoticeStartDays int64 `protobuf:"varint,11,opt,name=noticeStartDays,proto3" json:"noticeStartDays,omitempty"` NoticeEndDays int64 `protobuf:"varint,12,opt,name=noticeEndDays,proto3" json:"noticeEndDays,omitempty"` } @@ -592,6 +593,13 @@ func (x *Cmb) GetNotifyUrl() string { return "" } +func (x *Cmb) GetMultiNotifyUrl() string { + if x != nil { + return x.MultiNotifyUrl + } + return "" +} + func (x *Cmb) GetNoticeStartDays() int64 { if x != nil { return x.NoticeStartDays @@ -1626,7 +1634,7 @@ var file_conf_conf_proto_rawDesc = []byte{ 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, 0x50, 0x61, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x49, 0x44, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xd7, 0x02, 0x0a, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0xff, 0x02, 0x0a, 0x03, 0x43, 0x6d, 0x62, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x61, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6d, 0x32, 0x50, @@ -1643,113 +1651,115 @@ var file_conf_conf_proto_rawDesc = []byte{ 0x61, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x72, 0x67, 0x4e, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x72, 0x67, 0x4e, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x55, 0x72, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, 0x74, - 0x69, 0x66, 0x79, 0x55, 0x72, 0x6c, 0x12, 0x28, 0x0a, 0x0f, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, - 0x53, 0x74, 0x61, 0x72, 0x74, 0x44, 0x61, 0x79, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0f, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x44, 0x61, 0x79, 0x73, - 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x45, 0x6e, 0x64, 0x44, 0x61, 0x79, - 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x45, - 0x6e, 0x64, 0x44, 0x61, 0x79, 0x73, 0x22, 0xc6, 0x02, 0x0a, 0x0e, 0x57, 0x65, 0x63, 0x68, 0x61, - 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x4d, 0x51, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x61, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x53, - 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, - 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1e, 0x0a, - 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, - 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, - 0x70, 0x69, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, - 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x54, 0x61, 0x67, 0x55, 0x72, - 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, - 0x72, 0x54, 0x61, 0x67, 0x55, 0x72, 0x6c, 0x12, 0x26, 0x0a, 0x0e, 0x69, 0x73, 0x4f, 0x70, 0x65, - 0x6e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0e, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x22, - 0x9b, 0x01, 0x0a, 0x05, 0x41, 0x6c, 0x61, 0x72, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x77, 0x65, 0x62, - 0x68, 0x6f, 0x6f, 0x6b, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, - 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x55, 0x52, 0x4c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, - 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, - 0x74, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74, 0x41, 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x05, 0x61, 0x74, 0x41, 0x6c, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x74, 0x4d, 0x6f, 0x62, - 0x69, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x61, 0x74, 0x4d, 0x6f, - 0x62, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, - 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x77, - 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x84, 0x02, - 0x0a, 0x04, 0x43, 0x72, 0x6f, 0x6e, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x12, 0x44, - 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x61, 0x70, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x43, 0x72, 0x6f, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x4d, 0x61, 0x70, 0x1a, 0x3e, 0x0a, 0x0a, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, - 0x61, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x1a, 0x5e, 0x0a, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, - 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, - 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x43, 0x72, 0x6f, 0x6e, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x61, 0x70, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc4, 0x04, 0x0a, 0x05, 0x52, 0x64, 0x73, 0x4d, 0x51, 0x12, 0x3d, - 0x0a, 0x0b, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, 0x4d, 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, - 0x52, 0x0b, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x4f, 0x0a, - 0x14, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x6c, 0x69, 0x63, 0x65, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, + 0x69, 0x66, 0x79, 0x55, 0x72, 0x6c, 0x12, 0x26, 0x0a, 0x0e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x4e, + 0x6f, 0x74, 0x69, 0x66, 0x79, 0x55, 0x72, 0x6c, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, + 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x55, 0x72, 0x6c, 0x12, 0x28, + 0x0a, 0x0f, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x44, 0x61, 0x79, + 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x53, + 0x74, 0x61, 0x72, 0x74, 0x44, 0x61, 0x79, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x6f, 0x74, 0x69, + 0x63, 0x65, 0x45, 0x6e, 0x64, 0x44, 0x61, 0x79, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x0d, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x45, 0x6e, 0x64, 0x44, 0x61, 0x79, 0x73, 0x22, 0xc6, + 0x02, 0x0a, 0x0e, 0x57, 0x65, 0x63, 0x68, 0x61, 0x74, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x4d, + 0x51, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, + 0x79, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, + 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x61, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x67, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x67, + 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x74, + 0x61, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x18, 0x0a, + 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x26, 0x0a, 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x54, 0x61, 0x67, 0x55, 0x72, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0e, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x54, 0x61, 0x67, 0x55, 0x72, 0x6c, 0x12, + 0x26, 0x0a, 0x0e, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x43, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, + 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x43, + 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x22, 0x9b, 0x01, 0x0a, 0x05, 0x41, 0x6c, 0x61, 0x72, + 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x55, 0x52, 0x4c, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x77, 0x65, 0x62, 0x68, 0x6f, 0x6f, 0x6b, 0x55, 0x52, + 0x4c, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x74, 0x41, + 0x6c, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x61, 0x74, 0x41, 0x6c, 0x6c, 0x12, + 0x1c, 0x0a, 0x09, 0x61, 0x74, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x09, 0x61, 0x74, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x26, 0x0a, + 0x0e, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x4d, 0x6f, 0x62, 0x69, 0x6c, 0x65, 0x73, 0x18, + 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x77, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x4d, 0x6f, + 0x62, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x84, 0x02, 0x0a, 0x04, 0x43, 0x72, 0x6f, 0x6e, 0x12, 0x16, + 0x0a, 0x06, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, + 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x12, 0x44, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x4d, 0x61, 0x70, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x76, 0x6f, 0x75, + 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x43, 0x72, 0x6f, 0x6e, + 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x61, 0x70, 0x1a, 0x3e, 0x0a, 0x0a, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x61, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, + 0x4f, 0x70, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x4f, 0x70, + 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x1a, 0x5e, 0x0a, 0x0f, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x61, 0x70, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x35, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x2e, 0x43, 0x72, 0x6f, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x4d, 0x61, + 0x70, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xc4, 0x04, 0x0a, + 0x05, 0x52, 0x64, 0x73, 0x4d, 0x51, 0x12, 0x3d, 0x0a, 0x0b, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, - 0x4d, 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x14, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x3d, - 0x0a, 0x0b, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, 0x52, 0x65, 0x74, 0x72, 0x79, 0x18, 0x03, 0x20, + 0x4d, 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x0b, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x4f, 0x0a, 0x14, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, 0x54, + 0x69, 0x6d, 0x65, 0x53, 0x6c, 0x69, 0x63, 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, 0x4d, 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, - 0x52, 0x0b, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, 0x52, 0x65, 0x74, 0x72, 0x79, 0x12, 0x3d, 0x0a, - 0x0b, 0x72, 0x65, 0x74, 0x72, 0x79, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, 0x4d, 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, - 0x0b, 0x72, 0x65, 0x74, 0x72, 0x79, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x47, 0x0a, 0x10, - 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x74, 0x72, 0x79, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, - 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, 0x4d, 0x51, 0x2e, 0x51, 0x75, - 0x65, 0x75, 0x65, 0x52, 0x10, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, - 0x52, 0x65, 0x74, 0x72, 0x79, 0x12, 0x3b, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x64, 0x4e, 0x6f, 0x74, - 0x69, 0x66, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, 0x75, 0x63, - 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, 0x4d, 0x51, - 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, - 0x66, 0x79, 0x1a, 0xa6, 0x01, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x06, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x74, 0x72, - 0x79, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x74, 0x72, - 0x79, 0x4e, 0x75, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, 0x6e, 0x75, 0x6d, 0x57, 0x6f, 0x72, 0x6b, 0x65, - 0x72, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x6e, 0x75, 0x6d, 0x57, 0x6f, 0x72, - 0x6b, 0x65, 0x72, 0x73, 0x12, 0x35, 0x0a, 0x08, 0x77, 0x61, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x52, 0x08, 0x77, 0x61, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x22, 0xb9, 0x01, 0x0a, 0x09, - 0x41, 0x6c, 0x69, 0x59, 0x75, 0x6e, 0x53, 0x6d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x61, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x53, - 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, - 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, - 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x22, 0x3a, 0x0a, 0x04, 0x4c, 0x6f, 0x67, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, - 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, 0x63, - 0x65, 0x73, 0x73, 0x42, 0x17, 0x5a, 0x15, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2f, 0x63, - 0x70, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x14, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x53, 0x6c, 0x69, 0x63, + 0x65, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x3d, 0x0a, 0x0b, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, + 0x52, 0x65, 0x74, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, + 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, + 0x4d, 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x0b, 0x77, 0x65, 0x63, 0x68, 0x61, 0x74, + 0x52, 0x65, 0x74, 0x72, 0x79, 0x12, 0x3d, 0x0a, 0x0b, 0x72, 0x65, 0x74, 0x72, 0x79, 0x4e, 0x6f, + 0x74, 0x69, 0x66, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, 0x75, + 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, 0x4d, + 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x0b, 0x72, 0x65, 0x74, 0x72, 0x79, 0x4e, 0x6f, + 0x74, 0x69, 0x66, 0x79, 0x12, 0x47, 0x0a, 0x10, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x74, + 0x69, 0x66, 0x79, 0x52, 0x65, 0x74, 0x72, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, + 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x52, 0x64, 0x73, 0x4d, 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x10, 0x6f, 0x72, 0x64, + 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x65, 0x74, 0x72, 0x79, 0x12, 0x3b, 0x0a, + 0x0a, 0x75, 0x73, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x52, 0x64, 0x73, 0x4d, 0x51, 0x2e, 0x51, 0x75, 0x65, 0x75, 0x65, 0x52, 0x0a, + 0x75, 0x73, 0x65, 0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x1a, 0xa6, 0x01, 0x0a, 0x05, 0x51, + 0x75, 0x65, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x73, 0x4f, 0x70, + 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x69, 0x73, 0x4f, 0x70, 0x65, 0x6e, + 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x74, 0x72, 0x79, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0d, 0x52, 0x08, 0x72, 0x65, 0x74, 0x72, 0x79, 0x4e, 0x75, 0x6d, 0x12, 0x1e, 0x0a, 0x0a, + 0x6e, 0x75, 0x6d, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x0a, 0x6e, 0x75, 0x6d, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x12, 0x35, 0x0a, 0x08, + 0x77, 0x61, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x77, 0x61, 0x69, 0x74, 0x54, + 0x69, 0x6d, 0x65, 0x22, 0xb9, 0x01, 0x0a, 0x09, 0x41, 0x6c, 0x69, 0x59, 0x75, 0x6e, 0x53, 0x6d, + 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, + 0x79, 0x49, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, + 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x61, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x4b, 0x65, 0x79, 0x53, 0x65, 0x63, 0x72, 0x65, 0x74, 0x12, 0x1a, 0x0a, + 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x69, 0x67, + 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x69, 0x67, + 0x6e, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x28, 0x0a, 0x0f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, + 0x65, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, + 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x57, 0x61, 0x72, 0x6e, 0x69, 0x6e, 0x67, 0x22, + 0x3a, 0x0a, 0x04, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x75, 0x73, 0x69, 0x6e, + 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x62, 0x75, 0x73, 0x69, 0x6e, + 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x42, 0x17, 0x5a, 0x15, 0x76, + 0x6f, 0x75, 0x63, 0x68, 0x65, 0x72, 0x2f, 0x63, 0x70, 0x6e, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x3b, + 0x63, 0x6f, 0x6e, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/internal/conf/conf.proto b/internal/conf/conf.proto index 5787df9..f56e09f 100644 --- a/internal/conf/conf.proto +++ b/internal/conf/conf.proto @@ -88,6 +88,7 @@ message Cmb { string cmbKeyAlias = 8; string orgNo = 9; string notifyUrl = 10; + string multiNotifyUrl = 13; int64 noticeStartDays = 11; int64 noticeEndDays = 12; } diff --git a/internal/data/repoimpl/provider_set.go b/internal/data/repoimpl/provider_set.go index 9fd0991..dc58fc5 100644 --- a/internal/data/repoimpl/provider_set.go +++ b/internal/data/repoimpl/provider_set.go @@ -11,4 +11,6 @@ var ProviderRepoImplSet = wire.NewSet( NewOrderNotifyRepoImpl, NewWechatNotifyRegisterTagRepoImpl, NewOrderBakRepoImpl, + NewMultiNotifyDataRepoImpl, + NewMultiNotifyLogRepoImpl, ) diff --git a/internal/pkg/helper/utils_test.go b/internal/pkg/helper/utils_test.go index b8d2096..d09f8d6 100644 --- a/internal/pkg/helper/utils_test.go +++ b/internal/pkg/helper/utils_test.go @@ -1,9 +1,11 @@ package helper import ( + "encoding/json" "fmt" "testing" "time" + "voucher/internal/biz/do" ) func TestHashMod(t *testing.T) { @@ -46,3 +48,49 @@ func TestMd5(t *testing.T) { s := Md5(`{"product_no":"","start_time":"2025-04-20 09:00:00","end_time":"2025-05-01 00:00:00"}`) t.Log(s) } + +func TestLength(t *testing.T) { + + jsonStr := `{ + "id": "4ab2699d-e91d-5460-9810-25fd6d4c69a5", + "create_time": "2025-12-08T17:54:24+08:00", + "resource_type": "encrypt-resource", + "event_type": "COUPON.USE", + "summary": "代金券核销通知", + "original_type": "coupon", + "associated_data": "coupon", + "plain_text": { + "stock_creator_mchid": "1652465541", + "stock_id": "21386484", + "coupon_id": "142388354994", + "coupon_name": "银行卡多笔立减", + "description": "", + "status": "SENDED", + "create_time": "2025-12-08T17:50:48+08:00", + "coupon_type": "NORMAL", + "no_cash": false, + "singleitem": false, + "business_type": "", + "consume_information": { + "consume_time": "2025-12-08T17:54:24+08:00", + "consume_mchid": "1274938601", + "transaction_id": "4200002996202512083063051834", + "consume_amount": 16 + } + } +}` + s := len(jsonStr) + t.Log(s) + + var notify do.CouponNotification + err := json.Unmarshal([]byte(jsonStr), ¬ify) + if err != nil { + panic(err) + } + + // 输出验证 + fmt.Println("代金券ID:", notify.PlainText.CouponID) + fmt.Println("核销金额(分):", notify.PlainText.ConsumeInformation.ConsumeAmount) + fmt.Println("核销时间:", notify.PlainText.ConsumeInformation.ConsumeTime) + fmt.Println("核销时间:", notify.PlainText.ConsumeInformation.ConsumeTime.Format(time.DateTime)) +} diff --git a/internal/server/http.go b/internal/server/http.go index 55e33d6..2758dd4 100644 --- a/internal/server/http.go +++ b/internal/server/http.go @@ -11,7 +11,6 @@ import ( "github.com/go-kratos/kratos/v2/middleware/recovery" "github.com/go-kratos/kratos/v2/middleware/validate" "github.com/go-kratos/kratos/v2/transport/http" - "github.com/go-kratos/kratos/v2/transport/http/pprof" "github.com/gorilla/handlers" http2 "net/http" "time" @@ -27,15 +26,20 @@ func NewHTTPServer( log *log.Helper, accessLogger *log2.AccessLogger, cmb *service.CmbService, + tripartiteService *service.TripartiteService, ) *http.Server { //构建 server srv := buildHTTPServer(c, accessLogger, log) - srv.Handle("/voucher/debug/pprof/", pprof.NewHandler()) + + //srv.Handle("/voucher/debug/pprof/", pprof.NewHandler()) srv.Route("/voucher/").GET("ping", func(ctx http.Context) error { return ctx.String(http2.StatusOK, "pong") }) + // 启星 /voucher/qiXing/v1/notify + srv.Route("/voucher/").POST("qiXing/v1/notify", tripartiteService.QiXingNotify) + // 订单通知重试 -- 不健全 srv.Route("/voucher/").POST("orderNotifyRetry", cmb.OrderNotifyRetry) // 重试通知 diff --git a/internal/service/provider_set.go b/internal/service/provider_set.go index 984a7a0..fd9e579 100644 --- a/internal/service/provider_set.go +++ b/internal/service/provider_set.go @@ -8,4 +8,5 @@ import ( var ProviderSetService = wire.NewSet( NewVoucherService, NewCmbService, + NewTripartiteService, ) diff --git a/internal/service/qixing.go b/internal/service/qixing.go new file mode 100644 index 0000000..5c51940 --- /dev/null +++ b/internal/service/qixing.go @@ -0,0 +1,35 @@ +package service + +import ( + "encoding/json" + "fmt" + "github.com/go-kratos/kratos/v2/log" + "github.com/go-kratos/kratos/v2/transport/http" + "io" + "voucher/internal/biz" + "voucher/internal/biz/bo" +) + +type TripartiteService struct { + multiBiz *biz.MultiBiz +} + +func NewTripartiteService(multiBiz *biz.MultiBiz) *TripartiteService { + return &TripartiteService{multiBiz: multiBiz} +} + +func (srv *TripartiteService) QiXingNotify(ctx http.Context) error { + + bodyBytes, err := io.ReadAll(ctx.Request().Body) + if err != nil { + return fmt.Errorf("read body error: %v", err) + } + + var req *bo.WechatVoucherNotifyBo + if err = json.Unmarshal(bodyBytes, &req); err != nil { + log.Errorf("qixing notify error:%v,body:%s", err, string(bodyBytes)) + return fmt.Errorf("json unmarshal bodyBytes error: %v", err) + } + + return srv.multiBiz.Notify(ctx, "qixing_"+req.PlainText.StockCreatorMchid, req) +}