修复产品修改、删除
This commit is contained in:
34
apps/gateway/internal/logic/topup/alitopupcallbacklogic.go
Normal file
34
apps/gateway/internal/logic/topup/alitopupcallbacklogic.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package topup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"tianyuan-api/apps/sentinel/sentinel"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"tianyuan-api/apps/gateway/internal/svc"
|
||||
)
|
||||
|
||||
type AliTopUpCallbackLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAliTopUpCallbackLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AliTopUpCallbackLogic {
|
||||
return &AliTopUpCallbackLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AliTopUpCallbackLogic) AliTopUpCallback(r *http.Request) error {
|
||||
_, err := l.svcCtx.TopUpRpc.AliTopUpNotify(l.ctx, &sentinel.AliTopUpNotifyRequest{
|
||||
RawForm: r.Form.Encode(),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
40
apps/gateway/internal/logic/topup/alitopuplogic.go
Normal file
40
apps/gateway/internal/logic/topup/alitopuplogic.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package topup
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"tianyuan-api/apps/sentinel/sentinel"
|
||||
|
||||
"tianyuan-api/apps/gateway/internal/svc"
|
||||
"tianyuan-api/apps/gateway/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type AliTopUpLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewAliTopUpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AliTopUpLogic {
|
||||
return &AliTopUpLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AliTopUpLogic) AliTopUp(req *types.AliTopUpRequest) (resp *types.AliTopUpResponse, err error) {
|
||||
userId, ok := l.ctx.Value("userId").(int64)
|
||||
if !ok {
|
||||
return nil, errors.New("无法获取 userId")
|
||||
}
|
||||
up, err := l.svcCtx.TopUpRpc.AliTopUp(l.ctx, &sentinel.AliTopUpRequest{UserId: userId, Amount: req.Amount})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.AliTopUpResponse{
|
||||
PayUrl: up.PayUrl,
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user