cmb
This commit is contained in:
parent
73ce021b25
commit
8d421a8adc
|
|
@ -147,7 +147,20 @@ func (v *Cmb) NotifyConsume(ctx context.Context, order *bo.OrderBo, orderOutRequ
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return v.OrderNotifyRepo.Fail(ctx, orderNotify.ID, err.Error())
|
return v.OrderNotifyRepo.Fail(ctx, orderNotify.ID, err.Error())
|
||||||
}
|
}
|
||||||
responses, _ := json.Marshal(x)
|
|
||||||
|
|
||||||
return v.OrderNotifyRepo.Success(ctx, orderNotify.ID, string(responses))
|
bizStr, err := v.CmbMixRepo.VerifyResponse(ctx, x)
|
||||||
|
if err != nil {
|
||||||
|
return v.OrderNotifyRepo.Fail(ctx, orderNotify.ID, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
var s *v1.CmbNotifyReply
|
||||||
|
if err = json.Unmarshal([]byte(bizStr), &s); err != nil {
|
||||||
|
return v.OrderNotifyRepo.Fail(ctx, orderNotify.ID, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.RespCode != vo.CmbResponseStatusSuccess.GetValue() {
|
||||||
|
return v.OrderNotifyRepo.Fail(ctx, orderNotify.ID, s.RespMsg)
|
||||||
|
}
|
||||||
|
|
||||||
|
return v.OrderNotifyRepo.Success(ctx, orderNotify.ID, bizStr)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type CmbMixRepo interface {
|
type CmbMixRepo interface {
|
||||||
|
VerifyResponse(ctx context.Context, req *v1.CmbReply) (string, error)
|
||||||
OrderVerify(ctx context.Context, req *v1.CmbRequest) (*v1.CmbOrderRequest, error)
|
OrderVerify(ctx context.Context, req *v1.CmbRequest) (*v1.CmbOrderRequest, error)
|
||||||
ProductQueryVerify(ctx context.Context, req *v1.CmbRequest) (*v1.CmbQueryProductRequest, error)
|
ProductQueryVerify(ctx context.Context, req *v1.CmbRequest) (*v1.CmbQueryProductRequest, error)
|
||||||
GetMockRequest(ctx context.Context, bizContent string) (*v1.CmbRequest, error)
|
GetMockRequest(ctx context.Context, bizContent string) (*v1.CmbRequest, error)
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,26 @@ func (s *CmbMixRepoImpl) GetMockRequest(_ context.Context, bizContent string) (*
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *CmbMixRepoImpl) VerifyResponse(_ context.Context, req *v1.CmbReply) (string, error) {
|
||||||
|
str := cmb.SortStructStr(req)
|
||||||
|
|
||||||
|
b, err := cmb.Verify(s.bc.Cmb.CmbSm2Puk, str, req.Sign)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !b {
|
||||||
|
return "", errors.New("签名验证失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
bizStr, err := cmb.Decrypt(s.bc.Cmb.Sm2Prk, req.EncryptBody)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return bizStr, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (s *CmbMixRepoImpl) GetResponse(_ context.Context, reqBo *bo.CmbResponseBo) (*v1.CmbReply, error) {
|
func (s *CmbMixRepoImpl) GetResponse(_ context.Context, reqBo *bo.CmbResponseBo) (*v1.CmbReply, error) {
|
||||||
|
|
||||||
reply := &v1.CmbReply{
|
reply := &v1.CmbReply{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue