feat(main): fix url
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"qnc-server/app/user/cmd/api/internal/logic/agent"
|
||||
"qnc-server/app/user/cmd/api/internal/svc"
|
||||
"qnc-server/common/result"
|
||||
)
|
||||
|
||||
func GetAgentInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := agent.NewGetAgentInfoLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetAgentInfo()
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -21,16 +21,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/agent/apply",
|
||||
Path: "/apply",
|
||||
Handler: agent.ApplyForAgentHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/agent/audit/status",
|
||||
Path: "/audit/status",
|
||||
Handler: agent.GetAgentAuditStatusHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/info",
|
||||
Handler: agent.GetAgentInfoHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/v1"),
|
||||
rest.WithPrefix("/api/v1/agent"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
|
||||
48
app/user/cmd/api/internal/logic/agent/getagentinfologic.go
Normal file
48
app/user/cmd/api/internal/logic/agent/getagentinfologic.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/pkg/errors"
|
||||
"qnc-server/common/ctxdata"
|
||||
"qnc-server/common/xerr"
|
||||
|
||||
"qnc-server/app/user/cmd/api/internal/svc"
|
||||
"qnc-server/app/user/cmd/api/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetAgentInfoLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetAgentInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetAgentInfoLogic {
|
||||
return &GetAgentInfoLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetAgentInfoLogic) GetAgentInfo() (resp *types.AgentInfoResp, err error) {
|
||||
userID, err := ctxdata.GetUidFromCtx(l.ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理信息, %+v", err)
|
||||
}
|
||||
agent, err := l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return &types.AgentInfoResp{
|
||||
IsAgent: false,
|
||||
}, nil
|
||||
}
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "获取代理信息, %+v", err)
|
||||
}
|
||||
copier.Copy(&resp, agent)
|
||||
resp.IsAgent = true
|
||||
return resp, nil
|
||||
}
|
||||
@@ -61,10 +61,13 @@ func (a *AliPayService) CreateAlipayAppOrder(amount float64, subject string, out
|
||||
// CreateAlipayH5Order 创建支付宝H5支付订单
|
||||
func (a *AliPayService) CreateAlipayH5Order(amount float64, subject string, outTradeNo string, brand string) (string, error) {
|
||||
var returnURL string
|
||||
var notifyURL string
|
||||
if brand == "tyc" {
|
||||
returnURL = "https://www.tianyuancha.com/report"
|
||||
notifyURL = "https://www.tianyuancha.com/api/v1/pay/wechat/callback"
|
||||
} else {
|
||||
returnURL = a.config.ReturnURL
|
||||
notifyURL = a.config.NotifyUrl
|
||||
}
|
||||
client := a.AlipayClient
|
||||
totalAmount := lzUtils.ToAlipayAmount(amount)
|
||||
@@ -74,8 +77,8 @@ func (a *AliPayService) CreateAlipayH5Order(amount float64, subject string, outT
|
||||
Subject: subject,
|
||||
OutTradeNo: outTradeNo,
|
||||
TotalAmount: totalAmount,
|
||||
ProductCode: "QUICK_WAP_PAY", // H5支付专用产品码
|
||||
NotifyURL: a.config.NotifyUrl, // 异步回调通知地址
|
||||
ProductCode: "QUICK_WAP_PAY", // H5支付专用产品码
|
||||
NotifyURL: notifyURL, // 异步回调通知地址
|
||||
ReturnURL: returnURL,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -22,6 +22,13 @@ type AgentAuditStatusResp struct {
|
||||
AuditReason string `json:"audit_reason"`
|
||||
}
|
||||
|
||||
type AgentInfoResp struct {
|
||||
IsAgent bool `json:"is_agent"`
|
||||
Region string `json:"region"`
|
||||
Mobile string `json:"mobile"`
|
||||
WechatID string `json:"wechat_id"`
|
||||
}
|
||||
|
||||
type Feature struct {
|
||||
ID int64 `json:"id"` // 功能ID
|
||||
ApiID string `json:"api_id"` // API标识
|
||||
|
||||
Reference in New Issue
Block a user