feat(main): fix url

This commit is contained in:
2025-02-18 15:23:26 +08:00
parent 761796bd35
commit 6a5eab11ea
12 changed files with 616 additions and 53 deletions

View File

@@ -1,29 +1,31 @@
syntax = "v1"
info (
title: "代理服务"
desc: "代理服务接口"
author: "Liangzai"
email: "2440983361@qq.com"
version: "v1"
title: "代理服务"
desc: "代理服务接口"
author: "Liangzai"
email: "2440983361@qq.com"
version: "v1"
)
import (
"agent/agent.api"
"agent/agent.api"
)
@server (
prefix: api/v1
group: agent
prefix: api/v1/agent
group: agent
)
service main {
// 提交代理申请
@handler ApplyForAgent
post /agent/apply (AgentApplyReq) returns (AgentApplyResp)
@handler GetAgentInfo
get /info returns (AgentInfoResp)
// 查询代理申请状态
@handler GetAgentAuditStatus
get /agent/audit/status (AgentAuditStatusReq) returns (AgentAuditStatusResp)
// 提交代理申请
@handler ApplyForAgent
post /apply (AgentApplyReq) returns (AgentApplyResp)
// 查询代理申请状态
@handler GetAgentAuditStatus
get /audit/status (AgentAuditStatusReq) returns (AgentAuditStatusResp)
}

View File

@@ -9,6 +9,13 @@ info (
)
type (
AgentInfoResp {
isAgent bool `json:"is_agent"`
region string `json:"region"`
mobile string `json:"mobile"`
wechatID string `json:"wechat_id"`
}
// 代理申请请求参数
AgentApplyReq {
UserID int64 `json:"user_id"`

View File

@@ -53,9 +53,9 @@ service main {
@handler detail
get /user/detail returns (UserInfoResp)
@doc "get new token"
@handler getToken
post /user/getToken returns (MobileCodeLoginResp)
@doc "get new token"
@handler getToken
post /user/getToken returns (MobileCodeLoginResp)
}
//============================> auth v1 <============================

View File

@@ -35,8 +35,8 @@ Alipay:
PrivateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCvo8TmTNnVguKwMYrX0z01PfUlSS+AqwwCH1+/P39q6No+09yO1bjhy4LowtDfwKX8F+IZLl5Cx06f1M8KzPvjQliBAfMJ1FuTEOOXPmtE1YLAYIUMLbltR6Crnp16T28eF41Uo0PUo2ple/oSjW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Xu7YVgIccYbV7wdQhm7q3rxFI7hTkU6UL4ylRDQPCJDyhREUValf0DozS1XkdueM3MWWJ8i0N+G/MsohnjdQTnZT+DBQFqM5eEai/Y1AAWpMw5N5oS2O1barIR1iU2053QzeZwCyfuTuUFRjk+mSevhFSgDfKN5qKRTor7kDUQKBgB3fC6jO8XCwimPvpsiGnuddNAq/w8iqSjSwuSvbI0Q7Lq6rvAIw2AmkC5t4kW4JcZLUgDvAs4GFoPDYhoL73vc1e2c35VTNck6IxZSQzzQ9pfXFiLtTe6eqggN4EOPGHKLd92CMAgoeySsp3NydpGSx2N/NUqp8BkoFLQ/k2W9o"
AlipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2CqoCp95w/JV3RT/gzF4/8QmVT1HQNaeW7yUp+mA7x9AbjvlTW/+eRn6oGAL/XhZLjvHD0XjKLVKX0MJVS1aUQHEHEbOJN4Eu8II45OavD4iZISa7Kp9V6AM+i4qTyaeV2wNDnGxHQBaLVUGCfMR+56EK2YpORdE1H9uy72SSQseVb3bmpsV9EW/IJNmcVL/ut3uA1JWAoRmzlQ7ekxg7p8AYXzYPEHQr1tl7W+M4zv9wO9GKZCxIqMA8U3RP5npPfRaCfIRGzXzCqFEEUvWuidOB7frsvN4jiPD07qpL2Bi9LM1X/ee2kC/oM8Uhd7ERZhG8MbZfijZKxgrsDKBcwIDAQAB"
IsProduction: true
NotifyUrl: "https://www.quannengcha.com/api/v1/pay/alipay/callback"
ReturnURL: "https://www.quannengcha.com/report"
NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/alipay/callback"
ReturnURL: "https://www.tianyuancha.cn/report"
Wxpay:
AppID: "wxba8424db4771cc18"
AppSecret: "89646203d7f76eb7aef0d926b9efffaa"
@@ -44,8 +44,8 @@ Wxpay:
MchCertificateSerialNumber: "5369B8AEEBDCF7AF274510252E6A8C0659C30F61"
MchApiv3Key: "e3ea4cf0765f1e71b01bb387dfcdbc9f"
MchPrivateKeyPath: "etc/merchant/apiclient_key.pem"
NotifyUrl: "https://www.quannengcha.com/api/v1/pay/wechat/callback"
RefundNotifyUrl: "https://www.quannengcha.com/api/v1/wechat/refund_callback"
NotifyUrl: "https://www.tianyuancha.cn/api/v1/pay/wechat/callback"
RefundNotifyUrl: "https://www.tianyuancha.cn/api/v1/wechat/refund_callback"
Applepay:
ProductionVerifyURL: "https://api.storekit.itunes.apple.com/inApps/v1/transactions/receipt"
SandboxVerifyURL: "https://api.storekit-sandbox.itunes.apple.com/inApps/v1/transactions/receipt"

View File

@@ -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)
}
}

View File

@@ -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(

View 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
}

View File

@@ -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,
},
}

View File

@@ -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标识