This commit is contained in:
ziming 2025-05-20 16:27:40 +08:00
parent 6e05cf2045
commit bb5e9ee0e9
10 changed files with 49 additions and 50 deletions

View File

@ -1,4 +1,4 @@
package kx
package kog
// BBToWechatRequest 蓝色兄弟请求微信发券接口数据同步Api
type BBToWechatRequest struct {
@ -24,8 +24,8 @@ type BBToWechatRequest struct {
TransactionId string `protobuf:"bytes,18,opt,name=transactionId,proto3" json:"transactionId,omitempty"`
}
func (this *BBToWechatRequest) GetSynNotice() *SynNotice {
return &SynNotice{
func (this *BBToWechatRequest) GetNotice() *Notice {
return &Notice{
OutBizBo: this.TransactionId,
Type: NoticeTypeBBToWechat,
BizContent: this,

View File

@ -1,4 +1,4 @@
package kx
package kog
// CmbToBBRequest 招行请求蓝色兄弟发券接口数据同步Api
type CmbToBBRequest struct {
@ -18,8 +18,8 @@ type CmbToBBRequest struct {
Attach string `protobuf:"bytes,15,opt,name=attach,proto3" json:"attach,omitempty"`
}
func (this *CmbToBBRequest) GetSynNotice() *SynNotice {
return &SynNotice{
func (this *CmbToBBRequest) GetNotice() *Notice {
return &Notice{
OutBizBo: this.TransactionId,
Type: NoticeTypeCmbToBB,
BizContent: this,

View File

@ -1,4 +1,4 @@
package kx
package kog
type NoticeType uint8

View File

@ -0,0 +1,23 @@
package kog
import (
"encoding/json"
)
var _ ApiInterface = (*CmbToBBRequest)(nil)
var _ ApiInterface = (*BBToWechatRequest)(nil)
var _ ApiInterface = (*WechatToBBRequest)(nil)
type ApiInterface interface {
GetNotice() *Notice
}
type Notice struct {
OutBizBo string
Type NoticeType
BizContent ApiInterface
}
func (this *Notice) Marshal() ([]byte, error) {
return json.Marshal(this)
}

View File

@ -1,4 +1,4 @@
package kx
package kog
// WechatToBBRequest 微信回调蓝色兄弟接口数据同步Api
type WechatToBBRequest struct {
@ -30,8 +30,8 @@ type WechatToBBRequest struct {
GmtVoucherCreate string `protobuf:"bytes,21,opt,name=gmtVoucherCreate,proto3" json:"gmtVoucherCreate,omitempty"`
}
func (this *WechatToBBRequest) GetSynNotice() *SynNotice {
return &SynNotice{
func (this *WechatToBBRequest) GetNotice() *Notice {
return &Notice{
OutBizBo: this.OrderId,
Type: NoticeTypeWechatToBB,
BizContent: this,

View File

@ -1,23 +0,0 @@
package kx
import (
"encoding/json"
)
var _ SynApiInterface = (*CmbToBBRequest)(nil)
var _ SynApiInterface = (*BBToWechatRequest)(nil)
var _ SynApiInterface = (*WechatToBBRequest)(nil)
type SynApiInterface interface {
GetSynNotice() *SynNotice
}
type SynNotice struct {
OutBizBo string
Type NoticeType
BizContent SynApiInterface
}
func (this *SynNotice) Marshal() ([]byte, error) {
return json.Marshal(this)
}

View File

@ -2,9 +2,9 @@ package mixrepos
import (
"context"
"voucher/internal/biz/kx"
"voucher/internal/biz/kog"
)
type KxMixRepo interface {
Request(ctx context.Context, req *kx.SynNotice) error
Request(ctx context.Context, req *kog.Notice) error
}

View File

@ -10,7 +10,7 @@ import (
err2 "voucher/api/err"
v1 "voucher/api/v1"
"voucher/internal/biz/bo"
"voucher/internal/biz/kx"
"voucher/internal/biz/kog"
"voucher/internal/biz/vo"
)
@ -27,7 +27,7 @@ func (v *VoucherBiz) CmbOrder(ctx context.Context, request *v1.CmbRequest) (*v1.
return nil, err
}
// 通知kx
// 通知kg
b, _ := json.Marshal(reply)
_ = v.bbToWx(ctx, order, string(b))
@ -119,7 +119,7 @@ func (v *VoucherBiz) order(ctx context.Context, req *bo.OrderCreateReqBo, produc
// return nil, err
//}
voucherNo := order.OrderNo
voucherNo := order.OrderNo // mock成功
if err = v.success(ctx, order, voucherNo); err != nil {
return order, err
}
@ -221,7 +221,7 @@ func (c *VoucherBiz) OrderFail(ctx context.Context, err error) (*v1.CmbReply, er
func (v *VoucherBiz) cmbToBB(ctx context.Context, cmbReq *v1.CmbOrderRequest) error {
req := &kx.CmbToBBRequest{
req := &kog.CmbToBBRequest{
TransactionId: cmbReq.TransactionId,
ActivityId: cmbReq.ActivityId,
CmbUid: cmbReq.CmbUid,
@ -231,7 +231,7 @@ func (v *VoucherBiz) cmbToBB(ctx context.Context, cmbReq *v1.CmbOrderRequest) er
Attach: cmbReq.Attach,
}
return v.KxMixRepo.Request(ctx, req.GetSynNotice())
return v.KxMixRepo.Request(ctx, req.GetNotice())
}
func (v *VoucherBiz) bbToWx(ctx context.Context, order *bo.OrderBo, cmbRes string) error {
@ -241,7 +241,7 @@ func (v *VoucherBiz) bbToWx(ctx context.Context, order *bo.OrderBo, cmbRes strin
return err
}
req := &kx.BBToWechatRequest{
req := &kog.BBToWechatRequest{
StockId: order.BatchNo,
OutRequestNo: order.OrderNo,
AppId: order.AppID,
@ -254,12 +254,12 @@ func (v *VoucherBiz) bbToWx(ctx context.Context, order *bo.OrderBo, cmbRes strin
TransactionId: order.OutBizNo,
}
return v.KxMixRepo.Request(ctx, req.GetSynNotice())
return v.KxMixRepo.Request(ctx, req.GetNotice())
}
func (v *VoucherBiz) wxToBB(ctx context.Context, order *bo.OrderBo, wxReq *bo.WechatVoucherNotifyBo) error {
req := &kx.WechatToBBRequest{
req := &kog.WechatToBBRequest{
ActivityId: order.BatchNo,
ActivityName: wxReq.PlainText.CouponName,
VoucherId: order.VoucherNo,
@ -282,12 +282,12 @@ func (v *VoucherBiz) wxToBB(ctx context.Context, order *bo.OrderBo, wxReq *bo.We
req.UseTime = fmt.Sprintf("%d", useTime.Unix())
}
return v.KxMixRepo.Request(ctx, req.GetSynNotice())
return v.KxMixRepo.Request(ctx, req.GetNotice())
}
func (v *VoucherBiz) wxToBBRefund(ctx context.Context, order *bo.OrderBo) error {
req := &kx.WechatToBBRequest{
req := &kog.WechatToBBRequest{
ActivityId: order.BatchNo,
ActivityName: "",
VoucherId: order.VoucherNo,
@ -303,5 +303,5 @@ func (v *VoucherBiz) wxToBBRefund(ctx context.Context, order *bo.OrderBo) error
GmtVoucherCreate: fmt.Sprintf("%d", order.ReceiveSuccessTime.Unix()),
}
return v.KxMixRepo.Request(ctx, req.GetSynNotice())
return v.KxMixRepo.Request(ctx, req.GetNotice())
}

View File

@ -3,12 +3,12 @@ package mixrepoimpl
import (
"context"
"github.com/go-kratos/kratos/v2/log"
"voucher/internal/biz/kx"
"voucher/internal/biz/kog"
"voucher/internal/biz/mixrepos"
"voucher/internal/conf"
)
// KxMixRepoImpl kx 空港
// KxMixRepoImpl kog 空港
type KxMixRepoImpl struct {
bc *conf.Bootstrap
}
@ -17,7 +17,7 @@ func NewKxMixRepoImpl(bc *conf.Bootstrap) mixrepos.KxMixRepo {
return &KxMixRepoImpl{bc: bc}
}
func (s *KxMixRepoImpl) Request(ctx context.Context, req *kx.SynNotice) error {
func (s *KxMixRepoImpl) Request(ctx context.Context, req *kog.Notice) error {
body, err := req.Marshal()
if err != nil {

View File

@ -6,6 +6,5 @@ import (
)
func (c *CmbService) Order(ctx context.Context, request *v1.CmbRequest) (*v1.CmbReply, error) {
return c.VoucherBiz.CmbOrder(ctx, request)
}