This commit is contained in:
2026-03-02 12:46:26 +08:00
parent 9fe6a88670
commit 6db59f1dea
61 changed files with 5432 additions and 1706 deletions

View File

@@ -45,8 +45,10 @@ service main {
type (
// 创建功能请求
AdminCreateFeatureReq {
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
WhitelistPrice *float64 `json:"whitelist_price,optional"` // 白名单屏蔽价格(单位:元)
CostPrice *float64 `json:"cost_price,optional"` // 天远API调用成本价单位
}
// 创建功能响应
AdminCreateFeatureResp {
@@ -54,9 +56,11 @@ type (
}
// 更新功能请求
AdminUpdateFeatureReq {
Id string `path:"id"` // 功能ID
ApiId *string `json:"api_id,optional"` // API标识
Name *string `json:"name,optional"` // 描述
Id string `path:"id"` // 功能ID
ApiId *string `json:"api_id,optional"` // API标识
Name *string `json:"name,optional"` // 描述
WhitelistPrice *float64 `json:"whitelist_price,optional"` // 白名单屏蔽价格(单位:元)
CostPrice *float64 `json:"cost_price,optional"` // 天远API调用成本价单位
}
// 更新功能响应
AdminUpdateFeatureResp {
@@ -79,11 +83,13 @@ type (
}
// 功能列表项
FeatureListItem {
Id string `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
Id string `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
WhitelistPrice float64 `json:"whitelist_price"` // 白名单屏蔽价格(单位:元)
CostPrice float64 `json:"cost_price"` // 天远API调用成本价单位
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
// 获取功能列表响应
AdminGetFeatureListResp {
@@ -96,11 +102,13 @@ type (
}
// 获取功能详情响应
AdminGetFeatureDetailResp {
Id string `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
Id string `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
WhitelistPrice float64 `json:"whitelist_price"` // 白名单屏蔽价格(单位:元)
CostPrice float64 `json:"cost_price"` // 天远API调用成本价单位
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
// 配置功能示例数据请求
AdminConfigFeatureExampleReq {

View File

@@ -0,0 +1,93 @@
syntax = "v1"
info (
title: "后台统计面板服务"
desc: "后台统计面板相关接口"
author: "team"
version: "v1"
)
// ============================================
// 统计面板接口
// ============================================
@server (
prefix: /api/v1/admin/dashboard
group: admin_dashboard
middleware: AdminAuthInterceptor
)
service main {
// 获取统计面板数据
@handler AdminGetDashboardStatistics
get /statistics returns (AdminGetDashboardStatisticsResp)
}
type (
// 统计面板响应
AdminGetDashboardStatisticsResp {
// 订单统计
OrderStats AdminOrderStatistics `json:"order_stats"`
// 营收统计
RevenueStats AdminRevenueStatistics `json:"revenue_stats"`
// 代理统计
AgentStats AdminAgentStatistics `json:"agent_stats"`
// 利润统计
ProfitStats AdminProfitStatistics `json:"profit_stats"`
// 订单趋势最近7天
OrderTrend []AdminTrendData `json:"order_trend"`
// 营收趋势最近7天
RevenueTrend []AdminTrendData `json:"revenue_trend"`
}
// 订单统计
AdminOrderStatistics {
TodayCount int64 `json:"today_count"` // 今日订单数
MonthCount int64 `json:"month_count"` // 当月订单数
TotalCount int64 `json:"total_count"` // 总订单数
YesterdayCount int64 `json:"yesterday_count"` // 昨日订单数
ChangeRate float64 `json:"change_rate"` // 变化率(百分比)
}
// 营收统计
AdminRevenueStatistics {
TodayAmount float64 `json:"today_amount"` // 今日营收
MonthAmount float64 `json:"month_amount"` // 当月营收
TotalAmount float64 `json:"total_amount"` // 总营收
YesterdayAmount float64 `json:"yesterday_amount"` // 昨日营收
ChangeRate float64 `json:"change_rate"` // 变化率(百分比)
}
// 代理统计
AdminAgentStatistics {
TotalCount int64 `json:"total_count"` // 代理总数
TodayNew int64 `json:"today_new"` // 今日新增
MonthNew int64 `json:"month_new"` // 当月新增
}
// 利润统计
AdminProfitStatistics {
TodayProfit float64 `json:"today_profit"` // 今日利润
MonthProfit float64 `json:"month_profit"` // 当月利润
TotalProfit float64 `json:"total_profit"` // 总利润
TodayProfitRate float64 `json:"today_profit_rate"` // 今日利润率
MonthProfitRate float64 `json:"month_profit_rate"` // 当月利润率
TotalProfitRate float64 `json:"total_profit_rate"` // 总利润率
// 今日明细
TodayDetail AdminProfitDetail `json:"today_detail"`
// 当月明细
MonthDetail AdminProfitDetail `json:"month_detail"`
// 总计明细
TotalDetail AdminProfitDetail `json:"total_detail"`
}
// 利润明细
AdminProfitDetail {
Revenue float64 `json:"revenue"` // 营收
Commission float64 `json:"commission"` // 佣金
Rebate float64 `json:"rebate"` // 返利
CompanyTax float64 `json:"company_tax"` // 税务成本
ApiCost float64 `json:"api_cost"` // API调用成本
TaxIncome float64 `json:"tax_income"` // 提现收税
Profit float64 `json:"profit"` // 利润
ProfitRate float64 `json:"profit_rate"` // 利润率
}
// 趋势数据
AdminTrendData {
Date string `json:"date"` // 日期格式MM-DD
Value float64 `json:"value"` // 数值
}
)

View File

@@ -251,6 +251,32 @@ service main {
// 获取推广查询报告列表
@handler GetPromotionQueryList
get /promotion/query/list (GetPromotionQueryListReq) returns (GetPromotionQueryListResp)
// ============================================
// 用户模块白名单相关接口
// ============================================
@handler GetWhitelistFeatures
get /whitelist/features (GetWhitelistFeaturesReq) returns (GetWhitelistFeaturesResp)
// 创建白名单订单
@handler CreateWhitelistOrder
post /whitelist/order/create (CreateWhitelistOrderReq) returns (CreateWhitelistOrderResp)
// 获取用户白名单列表
@handler GetWhitelistList
get /whitelist/list (GetWhitelistListReq) returns (GetWhitelistListResp)
// 检查模块是否已下架(用于显示下架按钮状态)
@handler CheckFeatureWhitelistStatus
get /whitelist/check (CheckFeatureWhitelistStatusReq) returns (CheckFeatureWhitelistStatusResp)
// 下架单个模块(创建订单并支付)
@handler OfflineFeature
post /whitelist/offline (OfflineFeatureReq) returns (OfflineFeatureResp)
// 检查订单是否属于当前代理推广
@handler CheckOrderAgent
get /order/agent (CheckOrderAgentReq) returns (CheckOrderAgentResp)
}
type (
@@ -581,11 +607,82 @@ type (
List []PromotionQueryItem `json:"list"` // 列表
}
PromotionQueryItem {
Id string `json:"id"` // 查询ID
OrderId string `json:"order_id"` // 订单ID
ProductName string `json:"product_name"` // 产品名称
CreateTime string `json:"create_time"` // 创建时间
QueryState string `json:"query_state"` // 查询状态
Id string `json:"id"` // 查询ID
OrderId string `json:"order_id"` // 订单ID
ProductName string `json:"product_name"` // 产品名称
CreateTime string `json:"create_time"` // 创建时间
QueryState string `json:"query_state"` // 查询状态
Params map[string]interface{} `json:"params,optional"` // 查询参数(已脱敏)
Price float64 `json:"price"` // 查询价格
}
// ============================================
// 用户模块白名单相关类型
// ============================================
GetWhitelistFeaturesReq {}
GetWhitelistFeaturesResp {
List []WhitelistFeatureItem `json:"list"` // 可屏蔽的feature列表
}
WhitelistFeatureItem {
FeatureId string `json:"feature_id"` // Feature的UUID
FeatureApiId string `json:"feature_api_id"` // Feature的API标识
FeatureName string `json:"feature_name"` // Feature的名称
WhitelistPrice float64 `json:"whitelist_price"` // 屏蔽价格(单位:元)
}
CreateWhitelistOrderReq {
IdCard string `json:"id_card"` // 身份证号(查询对象标识)
FeatureIds []string `json:"feature_ids"` // 要屏蔽的feature ID列表
OrderId string `json:"order_id,optional"` // 关联的查询订单ID可选
}
CreateWhitelistOrderResp {
OrderId string `json:"order_id"` // 订单ID
OrderNo string `json:"order_no"` // 订单号
TotalAmount float64 `json:"total_amount"` // 总金额
}
GetWhitelistListReq {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
IdCard string `form:"id_card,optional"` // 身份证号(可选,用于筛选)
}
GetWhitelistListResp {
Total int64 `json:"total"` // 总数
List []WhitelistItem `json:"list"` // 列表
}
WhitelistItem {
Id string `json:"id"` // 白名单记录ID
IdCard string `json:"id_card"` // 身份证号
FeatureId string `json:"feature_id"` // Feature的UUID
FeatureApiId string `json:"feature_api_id"` // Feature的API标识
FeatureName string `json:"feature_name"` // Feature的名称
Amount float64 `json:"amount"` // 费用
Status int64 `json:"status"` // 状态1=生效2=已失效
StatusText string `json:"status_text"` // 状态文本
CreateTime string `json:"create_time"` // 创建时间
}
CheckFeatureWhitelistStatusReq {
IdCard string `form:"id_card"` // 身份证号
FeatureApiId string `form:"feature_api_id"` // Feature的API标识
QueryId string `form:"query_id,optional"` // 查询记录ID可选
}
CheckFeatureWhitelistStatusResp {
IsWhitelisted bool `json:"is_whitelisted"` // 是否在白名单中
WhitelistPrice float64 `json:"whitelist_price"` // 屏蔽价格单位0表示不支持下架
FeatureId string `json:"feature_id"` // Feature的UUID
DataDeleted bool `json:"data_deleted"` // 报告数据是否已删除
}
OfflineFeatureReq {
FeatureApiId string `json:"feature_api_id"` // Feature的API标识
QueryId string `json:"query_id"` // 查询记录IDQuery表的ID必选
}
OfflineFeatureResp {
Success bool `json:"success"` // 是否已完成下架
NeedPay bool `json:"need_pay"` // 是否需要发起支付
Amount float64 `json:"amount"` // 需要支付的金额0表示无需支付
}
CheckOrderAgentReq {
OrderId string `form:"order_id"` // 订单ID
}
CheckOrderAgentResp {
IsAgentOrder bool `json:"is_agent_order"` // 是否是当前代理推广的订单
}
)

View File

@@ -24,6 +24,7 @@ import "./admin/platform_user.api"
import "./admin/notification.api"
import "./admin/admin_product.api"
import "./admin/admin_feature.api"
import "./admin/dashboard.api"
import "./admin/admin_query.api"
import "./admin/admin_agent.api"
import "./admin/admin_api.api"

View File

@@ -0,0 +1,17 @@
package admin_dashboard
import (
"net/http"
"qnc-server/app/main/api/internal/logic/admin_dashboard"
"qnc-server/app/main/api/internal/svc"
"qnc-server/common/result"
)
func AdminGetDashboardStatisticsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
l := admin_dashboard.NewAdminGetDashboardStatisticsLogic(r.Context(), svcCtx)
resp, err := l.AdminGetDashboardStatistics()
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"qnc-server/app/main/api/internal/logic/agent"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/result"
"qnc-server/pkg/lzkit/validator"
)
func CheckFeatureWhitelistStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CheckFeatureWhitelistStatusReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewCheckFeatureWhitelistStatusLogic(r.Context(), svcCtx)
resp, err := l.CheckFeatureWhitelistStatus(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"qnc-server/app/main/api/internal/logic/agent"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/result"
"qnc-server/pkg/lzkit/validator"
)
func CheckOrderAgentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CheckOrderAgentReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewCheckOrderAgentLogic(r.Context(), svcCtx)
resp, err := l.CheckOrderAgent(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"qnc-server/app/main/api/internal/logic/agent"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/result"
"qnc-server/pkg/lzkit/validator"
)
func CreateWhitelistOrderHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreateWhitelistOrderReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewCreateWhitelistOrderLogic(r.Context(), svcCtx)
resp, err := l.CreateWhitelistOrder(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"qnc-server/app/main/api/internal/logic/agent"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/result"
"qnc-server/pkg/lzkit/validator"
)
func GetWhitelistFeaturesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetWhitelistFeaturesReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewGetWhitelistFeaturesLogic(r.Context(), svcCtx)
resp, err := l.GetWhitelistFeatures(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"qnc-server/app/main/api/internal/logic/agent"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/result"
"qnc-server/pkg/lzkit/validator"
)
func GetWhitelistListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetWhitelistListReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewGetWhitelistListLogic(r.Context(), svcCtx)
resp, err := l.GetWhitelistList(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -0,0 +1,29 @@
package agent
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"qnc-server/app/main/api/internal/logic/agent"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/result"
"qnc-server/pkg/lzkit/validator"
)
func OfflineFeatureHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.OfflineFeatureReq
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
if err := validator.Validate(req); err != nil {
result.ParamValidateErrorResult(r, w, err)
return
}
l := agent.NewOfflineFeatureLogic(r.Context(), svcCtx)
resp, err := l.OfflineFeature(&req)
result.HttpResult(r, w, resp, err)
}
}

View File

@@ -7,6 +7,7 @@ import (
admin_agent "qnc-server/app/main/api/internal/handler/admin_agent"
admin_api "qnc-server/app/main/api/internal/handler/admin_api"
admin_auth "qnc-server/app/main/api/internal/handler/admin_auth"
admin_dashboard "qnc-server/app/main/api/internal/handler/admin_dashboard"
admin_feature "qnc-server/app/main/api/internal/handler/admin_feature"
admin_menu "qnc-server/app/main/api/internal/handler/admin_menu"
admin_notification "qnc-server/app/main/api/internal/handler/admin_notification"
@@ -177,6 +178,20 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
rest.WithPrefix("/api/v1/admin/auth"),
)
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.AdminAuthInterceptor},
[]rest.Route{
{
Method: http.MethodGet,
Path: "/statistics",
Handler: admin_dashboard.AdminGetDashboardStatisticsHandler(serverCtx),
},
}...,
),
rest.WithPrefix("/api/v1/admin/dashboard"),
)
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.AdminAuthInterceptor},
@@ -671,6 +686,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/level/privilege",
Handler: agent.GetLevelPrivilegeHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/order/agent",
Handler: agent.CheckOrderAgentHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/product_config",
@@ -736,6 +756,31 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/upgrade/subordinate",
Handler: agent.UpgradeSubordinateHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/whitelist/check",
Handler: agent.CheckFeatureWhitelistStatusHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/whitelist/features",
Handler: agent.GetWhitelistFeaturesHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/whitelist/list",
Handler: agent.GetWhitelistListHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/whitelist/offline",
Handler: agent.OfflineFeatureHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/whitelist/order/create",
Handler: agent.CreateWhitelistOrderHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/withdrawal/apply",

View File

@@ -0,0 +1,256 @@
package admin_dashboard
import (
"context"
"time"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"qnc-server/app/main/api/internal/service"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/globalkey"
"qnc-server/common/xerr"
)
type AdminGetDashboardStatisticsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewAdminGetDashboardStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminGetDashboardStatisticsLogic {
return &AdminGetDashboardStatisticsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *AdminGetDashboardStatisticsLogic) AdminGetDashboardStatistics() (resp *types.AdminGetDashboardStatisticsResp, err error) {
loc, _ := time.LoadLocation("Asia/Shanghai")
now := time.Now().In(loc)
todayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, loc)
todayEnd := todayStart.AddDate(0, 0, 1)
yesterdayStart := todayStart.AddDate(0, 0, -1)
yesterdayEnd := todayStart
monthStart := time.Date(now.Year(), now.Month(), 1, 0, 0, 0, 0, loc)
monthEnd := monthStart.AddDate(0, 1, 0)
orderStats, err := l.calculateOrderStatistics(todayStart, todayEnd, yesterdayStart, yesterdayEnd, monthStart, monthEnd)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算订单统计失败, %v", err)
}
revenueStats, err := l.calculateRevenueStatistics(todayStart, todayEnd, yesterdayStart, yesterdayEnd, monthStart, monthEnd)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算营收统计失败, %v", err)
}
agentStats, err := l.calculateAgentStatistics(todayStart, monthStart)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算代理统计失败, %v", err)
}
profitStats, err := l.calculateProfitStatistics(todayStart, todayEnd, monthStart, monthEnd, revenueStats)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算利润统计失败, %v", err)
}
orderTrend, err := l.calculateOrderTrend(now, loc)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算订单趋势失败, %v", err)
}
revenueTrend, err := l.calculateRevenueTrend(now, loc)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "计算营收趋势失败, %v", err)
}
return &types.AdminGetDashboardStatisticsResp{
OrderStats: orderStats,
RevenueStats: revenueStats,
AgentStats: agentStats,
ProfitStats: profitStats,
OrderTrend: orderTrend,
RevenueTrend: revenueTrend,
}, nil
}
func (l *AdminGetDashboardStatisticsLogic) calculateOrderStatistics(todayStart, todayEnd, yesterdayStart, yesterdayEnd, monthStart, monthEnd time.Time) (types.AdminOrderStatistics, error) {
var stats types.AdminOrderStatistics
todayBuilder := l.svcCtx.OrderModel.SelectBuilder().
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", todayStart, todayEnd)
todayCount, err := l.svcCtx.OrderModel.FindCount(l.ctx, todayBuilder, "id")
if err != nil {
return stats, err
}
stats.TodayCount = todayCount
yesterdayBuilder := l.svcCtx.OrderModel.SelectBuilder().
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", yesterdayStart, yesterdayEnd)
yesterdayCount, _ := l.svcCtx.OrderModel.FindCount(l.ctx, yesterdayBuilder, "id")
stats.YesterdayCount = yesterdayCount
monthBuilder := l.svcCtx.OrderModel.SelectBuilder().
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", monthStart, monthEnd)
monthCount, _ := l.svcCtx.OrderModel.FindCount(l.ctx, monthBuilder, "id")
stats.MonthCount = monthCount
totalBuilder := l.svcCtx.OrderModel.SelectBuilder().Where("status = ?", "paid")
totalCount, _ := l.svcCtx.OrderModel.FindCount(l.ctx, totalBuilder, "id")
stats.TotalCount = totalCount
if stats.YesterdayCount > 0 {
stats.ChangeRate = float64(stats.TodayCount-stats.YesterdayCount) / float64(stats.YesterdayCount) * 100
} else if stats.TodayCount > 0 {
stats.ChangeRate = 100
}
return stats, nil
}
func (l *AdminGetDashboardStatisticsLogic) calculateRevenueStatistics(todayStart, todayEnd, yesterdayStart, yesterdayEnd, monthStart, monthEnd time.Time) (types.AdminRevenueStatistics, error) {
var stats types.AdminRevenueStatistics
todayBuilder := l.svcCtx.OrderModel.SelectBuilder().
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", todayStart, todayEnd)
todayAmount, _ := l.svcCtx.OrderModel.FindSum(l.ctx, todayBuilder, "amount")
stats.TodayAmount = todayAmount
yesterdayBuilder := l.svcCtx.OrderModel.SelectBuilder().
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", yesterdayStart, yesterdayEnd)
yesterdayAmount, _ := l.svcCtx.OrderModel.FindSum(l.ctx, yesterdayBuilder, "amount")
stats.YesterdayAmount = yesterdayAmount
monthBuilder := l.svcCtx.OrderModel.SelectBuilder().
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", monthStart, monthEnd)
monthAmount, _ := l.svcCtx.OrderModel.FindSum(l.ctx, monthBuilder, "amount")
stats.MonthAmount = monthAmount
totalBuilder := l.svcCtx.OrderModel.SelectBuilder().Where("status = ?", "paid")
totalAmount, _ := l.svcCtx.OrderModel.FindSum(l.ctx, totalBuilder, "amount")
stats.TotalAmount = totalAmount
if stats.YesterdayAmount > 0 {
stats.ChangeRate = (stats.TodayAmount - stats.YesterdayAmount) / stats.YesterdayAmount * 100
} else if stats.TodayAmount > 0 {
stats.ChangeRate = 100
}
return stats, nil
}
func (l *AdminGetDashboardStatisticsLogic) calculateAgentStatistics(todayStart, monthStart time.Time) (types.AdminAgentStatistics, error) {
var stats types.AdminAgentStatistics
totalCount, _ := l.svcCtx.AgentModel.FindCount(l.ctx, l.svcCtx.AgentModel.SelectBuilder(), "id")
stats.TotalCount = totalCount
todayBuilder := l.svcCtx.AgentModel.SelectBuilder().Where("create_time >= ?", todayStart)
todayNew, _ := l.svcCtx.AgentModel.FindCount(l.ctx, todayBuilder, "id")
stats.TodayNew = todayNew
monthBuilder := l.svcCtx.AgentModel.SelectBuilder().Where("create_time >= ?", monthStart)
monthNew, _ := l.svcCtx.AgentModel.FindCount(l.ctx, monthBuilder, "id")
stats.MonthNew = monthNew
return stats, nil
}
func (l *AdminGetDashboardStatisticsLogic) calculateProfitStatistics(todayStart, todayEnd, monthStart, monthEnd time.Time, revenueStats types.AdminRevenueStatistics) (types.AdminProfitStatistics, error) {
var stats types.AdminProfitStatistics
const companyTaxRate = 0.06
todayRevenue := revenueStats.TodayAmount
todayCommissionBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().
Where("del_state = ? AND status != ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 3, todayStart, todayEnd)
todayCommission, _ := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, todayCommissionBuilder, "amount")
todayRebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
Where("del_state = ? AND status != ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 3, todayStart, todayEnd)
todayRebate, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, todayRebateBuilder, "rebate_amount")
todayCompanyTax := todayRevenue * companyTaxRate
todayTaxIncomeBuilder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().
Where("del_state = ? AND tax_status = ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 2, todayStart, todayEnd)
todayTaxIncome, _ := l.svcCtx.AgentWithdrawalTaxModel.FindSum(l.ctx, todayTaxIncomeBuilder, "tax_amount")
todayApiCost := 0.0
if l.svcCtx.TianyuanapiCallLogService != nil {
todayApiStats, e := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{StartDate: todayStart, EndDate: todayEnd})
if e == nil {
todayApiCost = todayApiStats.TotalCost
}
}
stats.TodayProfit = todayRevenue - todayCommission - todayRebate - todayCompanyTax - todayApiCost + todayTaxIncome
if todayRevenue > 0 {
stats.TodayProfitRate = stats.TodayProfit / todayRevenue * 100
}
stats.TodayDetail = types.AdminProfitDetail{
Revenue: todayRevenue, Commission: todayCommission, Rebate: todayRebate,
CompanyTax: todayCompanyTax, ApiCost: todayApiCost, TaxIncome: todayTaxIncome,
Profit: stats.TodayProfit, ProfitRate: stats.TodayProfitRate,
}
monthRevenue := revenueStats.MonthAmount
monthCommissionBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().
Where("del_state = ? AND status != ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 3, monthStart, monthEnd)
monthCommission, _ := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, monthCommissionBuilder, "amount")
monthRebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().
Where("del_state = ? AND status != ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 3, monthStart, monthEnd)
monthRebate, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, monthRebateBuilder, "rebate_amount")
monthCompanyTax := monthRevenue * companyTaxRate
monthTaxIncomeBuilder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().
Where("del_state = ? AND tax_status = ? AND create_time >= ? AND create_time < ?", globalkey.DelStateNo, 2, monthStart, monthEnd)
monthTaxIncome, _ := l.svcCtx.AgentWithdrawalTaxModel.FindSum(l.ctx, monthTaxIncomeBuilder, "tax_amount")
monthApiCost := 0.0
if l.svcCtx.TianyuanapiCallLogService != nil {
monthApiStats, e := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{StartDate: monthStart, EndDate: monthEnd})
if e == nil {
monthApiCost = monthApiStats.TotalCost
}
}
stats.MonthProfit = monthRevenue - monthCommission - monthRebate - monthCompanyTax - monthApiCost + monthTaxIncome
if monthRevenue > 0 {
stats.MonthProfitRate = stats.MonthProfit / monthRevenue * 100
}
stats.MonthDetail = types.AdminProfitDetail{
Revenue: monthRevenue, Commission: monthCommission, Rebate: monthRebate,
CompanyTax: monthCompanyTax, ApiCost: monthApiCost, TaxIncome: monthTaxIncome,
Profit: stats.MonthProfit, ProfitRate: stats.MonthProfitRate,
}
totalRevenue := revenueStats.TotalAmount
totalCommissionBuilder := l.svcCtx.AgentCommissionModel.SelectBuilder().Where("del_state = ? AND status != ?", globalkey.DelStateNo, 3)
totalCommission, _ := l.svcCtx.AgentCommissionModel.FindSum(l.ctx, totalCommissionBuilder, "amount")
totalRebateBuilder := l.svcCtx.AgentRebateModel.SelectBuilder().Where("status != ?", 3)
totalRebate, _ := l.svcCtx.AgentRebateModel.FindSum(l.ctx, totalRebateBuilder, "rebate_amount")
totalCompanyTax := totalRevenue * companyTaxRate
totalTaxIncomeBuilder := l.svcCtx.AgentWithdrawalTaxModel.SelectBuilder().Where("tax_status = ?", 2)
totalTaxIncome, _ := l.svcCtx.AgentWithdrawalTaxModel.FindSum(l.ctx, totalTaxIncomeBuilder, "tax_amount")
totalApiCost := 0.0
if l.svcCtx.TianyuanapiCallLogService != nil {
totalApiStats, e := l.svcCtx.TianyuanapiCallLogService.GetStatistics(l.ctx, service.StatisticsFilter{})
if e == nil {
totalApiCost = totalApiStats.TotalCost
}
}
stats.TotalProfit = totalRevenue - totalCommission - totalRebate - totalCompanyTax - totalApiCost + totalTaxIncome
if totalRevenue > 0 {
stats.TotalProfitRate = stats.TotalProfit / totalRevenue * 100
}
stats.TotalDetail = types.AdminProfitDetail{
Revenue: totalRevenue, Commission: totalCommission, Rebate: totalRebate,
CompanyTax: totalCompanyTax, ApiCost: totalApiCost, TaxIncome: totalTaxIncome,
Profit: stats.TotalProfit, ProfitRate: stats.TotalProfitRate,
}
return stats, nil
}
func (l *AdminGetDashboardStatisticsLogic) calculateOrderTrend(now time.Time, loc *time.Location) ([]types.AdminTrendData, error) {
var trend []types.AdminTrendData
for i := 6; i >= 0; i-- {
date := now.AddDate(0, 0, -i)
dateStart := time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, loc)
dateEnd := dateStart.AddDate(0, 0, 1)
builder := l.svcCtx.OrderModel.SelectBuilder().
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", dateStart, dateEnd)
count, err := l.svcCtx.OrderModel.FindCount(l.ctx, builder, "id")
if err != nil {
return nil, err
}
trend = append(trend, types.AdminTrendData{Date: date.Format("01-02"), Value: float64(count)})
}
return trend, nil
}
func (l *AdminGetDashboardStatisticsLogic) calculateRevenueTrend(now time.Time, loc *time.Location) ([]types.AdminTrendData, error) {
var trend []types.AdminTrendData
for i := 6; i >= 0; i-- {
date := now.AddDate(0, 0, -i)
dateStart := time.Date(date.Year(), date.Month(), date.Day(), 0, 0, 0, 0, loc)
dateEnd := dateStart.AddDate(0, 0, 1)
builder := l.svcCtx.OrderModel.SelectBuilder().
Where("status = ? AND create_time >= ? AND create_time < ?", "paid", dateStart, dateEnd)
amount, err := l.svcCtx.OrderModel.FindSum(l.ctx, builder, "amount")
if err != nil {
return nil, err
}
trend = append(trend, types.AdminTrendData{Date: date.Format("01-02"), Value: amount})
}
return trend, nil
}

View File

@@ -34,6 +34,12 @@ func (l *AdminCreateFeatureLogic) AdminCreateFeature(req *types.AdminCreateFeatu
ApiId: req.ApiId,
Name: req.Name,
}
if req.WhitelistPrice != nil {
data.WhitelistPrice = *req.WhitelistPrice
}
if req.CostPrice != nil {
data.CostPrice = *req.CostPrice
}
// 2. 数据库操作
result, err := l.svcCtx.FeatureModel.Insert(l.ctx, nil, data)

View File

@@ -35,11 +35,13 @@ func (l *AdminGetFeatureDetailLogic) AdminGetFeatureDetail(req *types.AdminGetFe
// 2. 构建响应
resp = &types.AdminGetFeatureDetailResp{
Id: record.Id,
ApiId: record.ApiId,
Name: record.Name,
CreateTime: record.CreateTime.Format("2006-01-02 15:04:05"),
UpdateTime: record.UpdateTime.Format("2006-01-02 15:04:05"),
Id: record.Id,
ApiId: record.ApiId,
Name: record.Name,
WhitelistPrice: record.WhitelistPrice,
CostPrice: record.CostPrice,
CreateTime: record.CreateTime.Format("2006-01-02 15:04:05"),
UpdateTime: record.UpdateTime.Format("2006-01-02 15:04:05"),
}
return resp, nil

View File

@@ -49,11 +49,13 @@ func (l *AdminGetFeatureListLogic) AdminGetFeatureList(req *types.AdminGetFeatur
items := make([]types.FeatureListItem, 0, len(list))
for _, item := range list {
listItem := types.FeatureListItem{
Id: item.Id,
ApiId: item.ApiId,
Name: item.Name,
CreateTime: item.CreateTime.Format("2006-01-02 15:04:05"),
UpdateTime: item.UpdateTime.Format("2006-01-02 15:04:05"),
Id: item.Id,
ApiId: item.ApiId,
Name: item.Name,
WhitelistPrice: item.WhitelistPrice,
CostPrice: item.CostPrice,
CreateTime: item.CreateTime.Format("2006-01-02 15:04:05"),
UpdateTime: item.UpdateTime.Format("2006-01-02 15:04:05"),
}
items = append(items, listItem)
}

View File

@@ -46,6 +46,12 @@ func (l *AdminUpdateFeatureLogic) AdminUpdateFeature(req *types.AdminUpdateFeatu
if req.Name != nil && *req.Name != "" {
record.Name = *req.Name
}
if req.WhitelistPrice != nil {
record.WhitelistPrice = *req.WhitelistPrice
}
if req.CostPrice != nil {
record.CostPrice = *req.CostPrice
}
// 4. 执行更新操作
err = l.svcCtx.FeatureModel.UpdateWithVersion(l.ctx, nil, record)

View File

@@ -0,0 +1,72 @@
package agent
import (
"context"
"strings"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/app/main/model"
"qnc-server/common/xerr"
)
type CheckFeatureWhitelistStatusLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCheckFeatureWhitelistStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckFeatureWhitelistStatusLogic {
return &CheckFeatureWhitelistStatusLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CheckFeatureWhitelistStatusLogic) CheckFeatureWhitelistStatus(req *types.CheckFeatureWhitelistStatusReq) (resp *types.CheckFeatureWhitelistStatusResp, err error) {
if req.IdCard == "" {
return nil, errors.Wrapf(xerr.NewErrMsg("身份证号不能为空"), "")
}
if req.FeatureApiId == "" {
return nil, errors.Wrapf(xerr.NewErrMsg("模块API标识不能为空"), "")
}
mainApiId := req.FeatureApiId
if idx := strings.Index(req.FeatureApiId, "_"); idx > 0 {
mainApiId = req.FeatureApiId[:idx]
}
feature, err := l.svcCtx.FeatureModel.FindOneByApiId(l.ctx, mainApiId)
if err != nil {
if errors.Is(err, model.ErrNotFound) {
return nil, errors.Wrapf(xerr.NewErrMsg("模块不存在"), "")
}
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询模块信息失败, %v", err)
}
whitelistBuilder := l.svcCtx.UserFeatureWhitelistModel.SelectBuilder().
Where("id_card = ? AND feature_api_id = ? AND status = ?", req.IdCard, mainApiId, 1)
whitelists, err := l.svcCtx.UserFeatureWhitelistModel.FindAll(l.ctx, whitelistBuilder, "")
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询白名单记录失败, %v", err)
}
isWhitelisted := len(whitelists) > 0
dataDeleted := false
if req.QueryId != "" {
containsFeature, err := l.svcCtx.WhitelistService.CheckQueryDataContainsFeature(l.ctx, req.QueryId, req.FeatureApiId)
if err != nil {
logx.Errorf("检查报告数据是否包含模块失败:%v", err)
dataDeleted = true
} else {
dataDeleted = !containsFeature
}
} else {
dataDeleted = true
}
return &types.CheckFeatureWhitelistStatusResp{
IsWhitelisted: isWhitelisted,
WhitelistPrice: feature.WhitelistPrice,
FeatureId: feature.Id,
DataDeleted: dataDeleted,
}, nil
}

View File

@@ -0,0 +1,53 @@
package agent
import (
"context"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/app/main/model"
"qnc-server/common/ctxdata"
"qnc-server/common/xerr"
)
type CheckOrderAgentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCheckOrderAgentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CheckOrderAgentLogic {
return &CheckOrderAgentLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// CheckOrderAgent 判断订单是否为当前代理推广的订单(通过 agent_order 关联)
func (l *CheckOrderAgentLogic) CheckOrderAgent(req *types.CheckOrderAgentReq) (resp *types.CheckOrderAgentResp, err error) {
if req.OrderId == "" {
return &types.CheckOrderAgentResp{IsAgentOrder: false}, nil
}
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, model.ErrNotFound) {
return &types.CheckOrderAgentResp{IsAgentOrder: false}, nil
}
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
}
agentOrder, err := l.svcCtx.AgentOrderModel.FindOneByOrderId(l.ctx, req.OrderId)
if err != nil {
if errors.Is(err, model.ErrNotFound) {
return &types.CheckOrderAgentResp{IsAgentOrder: false}, nil
}
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询订单关联失败, %v", err)
}
return &types.CheckOrderAgentResp{IsAgentOrder: agentOrder.AgentId == agent.Id}, nil
}

View File

@@ -0,0 +1,127 @@
package agent
import (
"context"
"fmt"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/app/main/model"
"qnc-server/common/ctxdata"
"qnc-server/common/xerr"
)
type CreateWhitelistOrderLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewCreateWhitelistOrderLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateWhitelistOrderLogic {
return &CreateWhitelistOrderLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *CreateWhitelistOrderLogic) CreateWhitelistOrder(req *types.CreateWhitelistOrderReq) (resp *types.CreateWhitelistOrderResp, err error) {
userID, err := ctxdata.GetUidFromCtx(l.ctx)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户信息失败, %v", err)
}
_, err = l.svcCtx.AgentModel.FindOneByUserId(l.ctx, userID)
if err != nil {
if errors.Is(err, model.ErrNotFound) {
return nil, errors.Wrapf(xerr.NewErrMsg("您不是代理"), "")
}
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理信息失败, %v", err)
}
if req.IdCard == "" {
return nil, errors.Wrapf(xerr.NewErrMsg("身份证号不能为空"), "")
}
if len(req.FeatureIds) == 0 {
return nil, errors.Wrapf(xerr.NewErrMsg("请至少选择一个模块"), "")
}
var totalAmount float64
var orderItems []struct {
FeatureId string
FeatureApiId string
FeatureName string
Price float64
}
for _, featureId := range req.FeatureIds {
feature, err := l.svcCtx.FeatureModel.FindOne(l.ctx, featureId)
if err != nil {
if errors.Is(err, model.ErrNotFound) {
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("模块不存在: %s", featureId)), "")
}
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询模块信息失败, %v", err)
}
whitelistPrice := feature.WhitelistPrice
if whitelistPrice <= 0 {
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("模块 %s 不支持白名单屏蔽", feature.Name)), "")
}
whitelistBuilder := l.svcCtx.UserFeatureWhitelistModel.SelectBuilder().
Where("id_card = ? AND feature_id = ?", req.IdCard, featureId)
existing, err := l.svcCtx.UserFeatureWhitelistModel.FindAll(l.ctx, whitelistBuilder, "")
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询白名单记录失败, %v", err)
}
for _, item := range existing {
if item.Status == 1 {
return nil, errors.Wrapf(xerr.NewErrMsg(fmt.Sprintf("身份证号 %s 的模块 %s 已经加入白名单", req.IdCard, feature.Name)), "")
}
}
totalAmount += whitelistPrice
orderItems = append(orderItems, struct {
FeatureId string
FeatureApiId string
FeatureName string
Price float64
}{
FeatureId: feature.Id, FeatureApiId: feature.ApiId, FeatureName: feature.Name, Price: whitelistPrice,
})
}
base := l.svcCtx.AlipayService.GenerateOutTradeNo()
orderNo := "W_" + base
if len(orderNo) > 32 {
orderNo = orderNo[:32]
}
var orderId string
err = l.svcCtx.WhitelistOrderModel.Trans(l.ctx, func(ctx context.Context, session sqlx.Session) error {
order := &model.WhitelistOrder{
Id: uuid.NewString(), OrderNo: orderNo, UserId: userID, IdCard: req.IdCard,
TotalAmount: totalAmount, Status: 1,
}
_, err := l.svcCtx.WhitelistOrderModel.Insert(ctx, session, order)
if err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "创建订单失败, %v", err)
}
orderId = order.Id
for _, item := range orderItems {
orderItem := &model.WhitelistOrderItem{
Id: uuid.NewString(), OrderId: orderId, FeatureId: item.FeatureId,
FeatureApiId: item.FeatureApiId, FeatureName: item.FeatureName, Price: item.Price,
}
if _, err := l.svcCtx.WhitelistOrderItemModel.Insert(ctx, session, orderItem); err != nil {
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "创建订单明细失败, %v", err)
}
}
return nil
})
if err != nil {
return nil, err
}
return &types.CreateWhitelistOrderResp{
OrderId: orderId, OrderNo: orderNo, TotalAmount: totalAmount,
}, nil
}

View File

@@ -0,0 +1,45 @@
package agent
import (
"context"
"github.com/zeromicro/go-zero/core/logx"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/xerr"
"github.com/pkg/errors"
)
type GetWhitelistFeaturesLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetWhitelistFeaturesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWhitelistFeaturesLogic {
return &GetWhitelistFeaturesLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// GetWhitelistFeatures 返回支持白名单屏蔽的 feature 列表whitelist_price > 0
func (l *GetWhitelistFeaturesLogic) GetWhitelistFeatures(req *types.GetWhitelistFeaturesReq) (resp *types.GetWhitelistFeaturesResp, err error) {
builder := l.svcCtx.FeatureModel.SelectBuilder().Where("whitelist_price > ?", 0)
list, err := l.svcCtx.FeatureModel.FindAll(l.ctx, builder, "id ASC")
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询功能列表失败, %v", err)
}
items := make([]types.WhitelistFeatureItem, 0, len(list))
for _, f := range list {
items = append(items, types.WhitelistFeatureItem{
FeatureId: f.Id,
FeatureApiId: f.ApiId,
FeatureName: f.Name,
WhitelistPrice: f.WhitelistPrice,
})
}
return &types.GetWhitelistFeaturesResp{List: items}, nil
}

View File

@@ -0,0 +1,77 @@
package agent
import (
"context"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/ctxdata"
"qnc-server/common/xerr"
)
type GetWhitelistListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetWhitelistListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetWhitelistListLogic {
return &GetWhitelistListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func statusToText(status int64) string {
switch status {
case 1:
return "生效"
case 2:
return "已失效"
default:
return ""
}
}
func (l *GetWhitelistListLogic) GetWhitelistList(req *types.GetWhitelistListReq) (resp *types.GetWhitelistListResp, err error) {
userID, err := ctxdata.GetUidFromCtx(l.ctx)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户信息失败, %v", err)
}
if req.Page <= 0 {
req.Page = 1
}
if req.PageSize <= 0 || req.PageSize > 100 {
req.PageSize = 10
}
builder := l.svcCtx.UserFeatureWhitelistModel.SelectBuilder().Where("user_id = ?", userID)
if req.IdCard != "" {
builder = builder.Where("id_card = ?", req.IdCard)
}
list, total, err := l.svcCtx.UserFeatureWhitelistModel.FindPageListByPageWithTotal(l.ctx, builder, req.Page, req.PageSize, "create_time DESC")
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询白名单列表失败, %v", err)
}
items := make([]types.WhitelistItem, 0, len(list))
for _, r := range list {
featureName := r.FeatureApiId
if f, e := l.svcCtx.FeatureModel.FindOne(l.ctx, r.FeatureId); e == nil {
featureName = f.Name
}
items = append(items, types.WhitelistItem{
Id: r.Id,
IdCard: r.IdCard,
FeatureId: r.FeatureId,
FeatureApiId: r.FeatureApiId,
FeatureName: featureName,
Amount: r.Amount,
Status: r.Status,
StatusText: statusToText(r.Status),
CreateTime: r.CreateTime.Format("2006-01-02 15:04:05"),
})
}
return &types.GetWhitelistListResp{Total: total, List: items}, nil
}

View File

@@ -0,0 +1,70 @@
package agent
import (
"context"
"encoding/json"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"qnc-server/app/main/api/internal/svc"
"qnc-server/app/main/api/internal/types"
"qnc-server/common/ctxdata"
"qnc-server/common/xerr"
)
type OfflineFeatureLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewOfflineFeatureLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OfflineFeatureLogic {
return &OfflineFeatureLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *OfflineFeatureLogic) OfflineFeature(req *types.OfflineFeatureReq) (resp *types.OfflineFeatureResp, err error) {
userID, err := ctxdata.GetUidFromCtx(l.ctx)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取用户信息失败, %v", err)
}
if req.FeatureApiId == "" || req.QueryId == "" {
return nil, errors.Wrapf(xerr.NewErrMsg("模块标识和查询记录ID不能为空"), "")
}
// 从 Query 获取 id_card
query, err := l.svcCtx.QueryModel.FindOne(l.ctx, req.QueryId)
if err != nil {
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询记录不存在或查询失败, %v", err)
}
idCard := ""
if query.QueryParams != "" {
var params map[string]interface{}
if e := json.Unmarshal([]byte(query.QueryParams), &params); e == nil {
if v, ok := params["id_card"]; ok {
if s, ok := v.(string); ok {
idCard = s
}
}
}
}
if idCard == "" {
return nil, errors.Wrapf(xerr.NewErrMsg("无法从查询记录中获取身份证号"), "")
}
needPay, amount, whitelistCreated, err := l.svcCtx.WhitelistService.ProcessOfflineFeature(l.ctx, nil, idCard, req.FeatureApiId, userID, req.QueryId)
if err != nil {
return nil, err
}
if whitelistCreated && !needPay {
if err := l.svcCtx.WhitelistService.DeleteFeatureFromQueryData(l.ctx, nil, req.QueryId, req.FeatureApiId); err != nil {
logx.Errorf("从报告数据中删除模块失败: %v", err)
}
return &types.OfflineFeatureResp{Success: true, NeedPay: false, Amount: 0}, nil
}
if needPay {
return &types.OfflineFeatureResp{Success: false, NeedPay: true, Amount: amount}, nil
}
return &types.OfflineFeatureResp{Success: true, NeedPay: false, Amount: 0}, nil
}

View File

@@ -115,6 +115,8 @@ func BuildEncryptedQuery(ctx context.Context, svcCtx *svc.ServiceContext, queryM
if err != nil {
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 报告结构体复制失败, %v", err)
}
// 显式写入查询记录 ID供前端报告页「模块下架」等白名单能力使用
query.Id = queryModel.Id
product, err := svcCtx.ProductModel.FindOne(ctx, queryModel.ProductId)
if err != nil {
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 获取商品信息失败, %v", err)

View File

@@ -33,19 +33,33 @@ func generateAuthDateRange() string {
}
type ApiRequestService struct {
config config.Config
featureModel model.FeatureModel
productFeatureModel model.ProductFeatureModel
tianyuanapi *tianyuanapi.Client
config config.Config
featureModel model.FeatureModel
productFeatureModel model.ProductFeatureModel
userFeatureWhitelistModel model.UserFeatureWhitelistModel
whitelistService *WhitelistService
tianyuanapi *tianyuanapi.Client
tianyuanapiCallLogService *TianyuanapiCallLogService
}
// NewApiRequestService 是一个构造函数,用于初始化 ApiRequestService
func NewApiRequestService(c config.Config, featureModel model.FeatureModel, productFeatureModel model.ProductFeatureModel, tianyuanapi *tianyuanapi.Client) *ApiRequestService {
// NewApiRequestService 构造函数
func NewApiRequestService(
c config.Config,
featureModel model.FeatureModel,
productFeatureModel model.ProductFeatureModel,
userFeatureWhitelistModel model.UserFeatureWhitelistModel,
tianyuanapi *tianyuanapi.Client,
tianyuanapiCallLogService *TianyuanapiCallLogService,
whitelistService *WhitelistService,
) *ApiRequestService {
return &ApiRequestService{
config: c,
featureModel: featureModel,
productFeatureModel: productFeatureModel,
tianyuanapi: tianyuanapi,
config: c,
featureModel: featureModel,
productFeatureModel: productFeatureModel,
userFeatureWhitelistModel: userFeatureWhitelistModel,
tianyuanapi: tianyuanapi,
tianyuanapiCallLogService: tianyuanapiCallLogService,
whitelistService: whitelistService,
}
}
@@ -61,23 +75,33 @@ type APIResponseData struct {
func (a *ApiRequestService) ProcessRequests(params []byte, productID string) ([]byte, error) {
var ctx, cancel = context.WithCancel(context.Background())
defer cancel()
build := a.productFeatureModel.SelectBuilder().Where(squirrel.Eq{
"product_id": productID,
})
// 白名单:已下架模块直接返回占位成功,不调用天远 API
idCard := gjson.GetBytes(params, "id_card").String()
var whitelistedFeatureApiIds map[string]bool
if a.whitelistService != nil {
whitelistedFeatureApiIds, _ = a.whitelistService.GetWhitelistedFeatureApisByIdCard(ctx, idCard)
} else {
whitelistedFeatureApiIds = make(map[string]bool)
}
build := a.productFeatureModel.SelectBuilder().Where(squirrel.Eq{
"product_id": productID,
})
productFeatureList, findProductFeatureErr := a.productFeatureModel.FindAll(ctx, build, "")
if findProductFeatureErr != nil {
return nil, findProductFeatureErr
}
var featureIDs []string
isImportantMap := make(map[string]int64, len(productFeatureList))
var featureIDs []string
isImportantMap := make(map[string]int64, len(productFeatureList))
for _, pf := range productFeatureList {
featureIDs = append(featureIDs, pf.FeatureId)
isImportantMap[pf.FeatureId] = pf.IsImportant
featureIDs = append(featureIDs, pf.FeatureId)
isImportantMap[pf.FeatureId] = pf.IsImportant
}
if len(featureIDs) == 0 {
return nil, errors.New("featureIDs 是空的")
}
builder := a.featureModel.SelectBuilder().Where(squirrel.Eq{"id": featureIDs})
builder := a.featureModel.SelectBuilder().Where(squirrel.Eq{"id": featureIDs})
featureList, findFeatureErr := a.featureModel.FindAll(ctx, builder, "")
if findFeatureErr != nil {
return nil, findFeatureErr
@@ -109,12 +133,19 @@ func (a *ApiRequestService) ProcessRequests(params []byte, productID string) ([]
Success: false,
}
timestamp := time.Now().Format("2006-01-02 15:04:05")
// 白名单:已下架模块直接返回占位成功
if whitelistedFeatureApiIds[feature.ApiId] {
result.Success = true
result.Timestamp = timestamp
result.Data = []byte("null")
resultsCh <- result
return
}
var (
resp json.RawMessage
preprocessErr error
)
// 若 isImportantMap[feature.ID] == 1则表示需要在出错时重试
isImportant := isImportantMap[feature.Id] == 1
isImportant := isImportantMap[feature.Id] == 1
tryCount := 0
for {
tryCount++

View File

@@ -0,0 +1,190 @@
package service
import (
"context"
"database/sql"
"encoding/json"
"fmt"
"time"
"github.com/Masterminds/squirrel"
"github.com/zeromicro/go-zero/core/logx"
"qnc-server/app/main/model"
)
// TianyuanapiCallLogService 天元API调用记录服务
type TianyuanapiCallLogService struct {
tianyuanapiCallLogModel model.TianyuanapiCallLogModel
featureModel model.FeatureModel
}
// NewTianyuanapiCallLogService 创建天元API调用记录服务
func NewTianyuanapiCallLogService(
tianyuanapiCallLogModel model.TianyuanapiCallLogModel,
featureModel model.FeatureModel,
) *TianyuanapiCallLogService {
return &TianyuanapiCallLogService{
tianyuanapiCallLogModel: tianyuanapiCallLogModel,
featureModel: featureModel,
}
}
// CallLogOptions 调用记录选项
type CallLogOptions struct {
FeatureID string // 功能ID
ApiID string // API标识YYSYBE08
OrderID string // 订单ID可选
QueryID string // 查询ID可选
CallStatus int64 // 调用状态0=失败1=成功
ResponseTime int64 // 响应耗时(毫秒)
ErrorCode string // 错误码(失败时)
ErrorMessage string // 错误信息(失败时)
RequestParams interface{} // 请求参数(可选)
ResponseData interface{} // 响应数据(可选)
TransactionID string // 天元API流水号
}
// RecordCall 记录天元API调用
func (s *TianyuanapiCallLogService) RecordCall(ctx context.Context, opts CallLogOptions) error {
// 1. 获取feature的成本价
costPrice := 0.00
if opts.CallStatus == 1 { // 只有成功才计算成本
if opts.FeatureID == "" {
logx.Infof("记录API调用时feature_id为空api_id=%s无法获取成本价", opts.ApiID)
} else {
feature, err := s.featureModel.FindOne(ctx, opts.FeatureID)
if err == nil {
costPrice = feature.CostPrice
logx.Infof("记录API调用 - feature_id=%s, api_id=%s, cost_price=%f", opts.FeatureID, opts.ApiID, costPrice)
} else {
logx.Errorf("查询feature成本价失败feature_id=%s, api_id=%s, err=%v", opts.FeatureID, opts.ApiID, err)
}
}
}
// 2. 转换参数和响应为JSON字符串
var requestParamsStr, responseDataStr *string
if opts.RequestParams != nil {
if bytes, err := json.Marshal(opts.RequestParams); err == nil {
jsonStr := string(bytes)
requestParamsStr = &jsonStr
}
}
if opts.ResponseData != nil {
if bytes, err := json.Marshal(opts.ResponseData); err == nil {
jsonStr := string(bytes)
if len(jsonStr) > 1000 {
jsonStr = jsonStr[:1000] + "...[truncated]"
}
responseDataStr = &jsonStr
}
}
// 3. 构建调用记录
callTime := time.Now()
deleteTime := sql.NullTime{}
callLog := &model.TianyuanapiCallLog{
FeatureId: opts.FeatureID,
ApiId: opts.ApiID,
OrderId: sql.NullString{},
QueryId: sql.NullString{},
CallStatus: opts.CallStatus,
CallTime: callTime,
ResponseTime: sql.NullInt64{},
CostPrice: costPrice,
ErrorCode: sql.NullString{},
ErrorMessage: sql.NullString{},
RequestParams: sql.NullString{},
ResponseData: sql.NullString{},
TransactionId: sql.NullString{},
CreateTime: callTime,
UpdateTime: callTime,
DeleteTime: deleteTime,
DelState: 0,
Version: 0,
}
if opts.OrderID != "" {
callLog.OrderId = sql.NullString{String: opts.OrderID, Valid: true}
}
if opts.QueryID != "" {
callLog.QueryId = sql.NullString{String: opts.QueryID, Valid: true}
}
if opts.ResponseTime > 0 {
callLog.ResponseTime = sql.NullInt64{Int64: opts.ResponseTime, Valid: true}
}
if opts.ErrorCode != "" {
callLog.ErrorCode = sql.NullString{String: opts.ErrorCode, Valid: true}
}
if opts.ErrorMessage != "" {
callLog.ErrorMessage = sql.NullString{String: opts.ErrorMessage, Valid: true}
}
if requestParamsStr != nil {
callLog.RequestParams = sql.NullString{String: *requestParamsStr, Valid: true}
}
if responseDataStr != nil {
callLog.ResponseData = sql.NullString{String: *responseDataStr, Valid: true}
}
if opts.TransactionID != "" {
callLog.TransactionId = sql.NullString{String: opts.TransactionID, Valid: true}
}
_, err := s.tianyuanapiCallLogModel.Insert(ctx, nil, callLog)
if err != nil {
logx.Errorf("插入天元API调用记录失败feature_id=%s, api_id=%s, err=%v", opts.FeatureID, opts.ApiID, err)
return fmt.Errorf("插入调用记录失败: %w", err)
}
return nil
}
// StatisticsFilter 统计过滤条件
type StatisticsFilter struct {
FeatureID string
ApiID string
StartDate time.Time
EndDate time.Time
}
// Statistics 统计信息
type Statistics struct {
TotalCalls int64
SuccessCalls int64
FailedCalls int64
TotalCost float64
}
// GetStatistics 获取统计信息
func (s *TianyuanapiCallLogService) GetStatistics(ctx context.Context, filter StatisticsFilter) (*Statistics, error) {
builder := s.tianyuanapiCallLogModel.SelectBuilder()
if filter.FeatureID != "" {
builder = builder.Where(squirrel.Eq{"feature_id": filter.FeatureID})
}
if filter.ApiID != "" {
builder = builder.Where(squirrel.Eq{"api_id": filter.ApiID})
}
if !filter.StartDate.IsZero() {
builder = builder.Where(squirrel.GtOrEq{"call_time": filter.StartDate})
}
if !filter.EndDate.IsZero() {
builder = builder.Where(squirrel.Lt{"call_time": filter.EndDate})
}
totalCalls, err := s.tianyuanapiCallLogModel.FindCount(ctx, builder, "id")
if err != nil {
return nil, fmt.Errorf("统计总调用次数失败: %w", err)
}
successBuilder := builder.Where(squirrel.Eq{"call_status": 1})
successCalls, err := s.tianyuanapiCallLogModel.FindCount(ctx, successBuilder, "id")
if err != nil {
return nil, fmt.Errorf("统计成功次数失败: %w", err)
}
totalCost, err := s.tianyuanapiCallLogModel.FindSum(ctx, successBuilder, "cost_price")
if err != nil {
return nil, fmt.Errorf("统计总成本失败: %w", err)
}
return &Statistics{
TotalCalls: totalCalls,
SuccessCalls: successCalls,
FailedCalls: totalCalls - successCalls,
TotalCost: totalCost,
}, nil
}

View File

@@ -0,0 +1,450 @@
package service
import (
"context"
"database/sql"
"encoding/hex"
"encoding/json"
"strings"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/zeromicro/go-zero/core/logx"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"qnc-server/app/main/api/internal/config"
"qnc-server/app/main/model"
"qnc-server/common/xerr"
"qnc-server/pkg/lzkit/crypto"
"qnc-server/pkg/lzkit/lzUtils"
)
// WhitelistService 白名单领域服务
type WhitelistService struct {
config config.Config
UserFeatureWhitelistModel model.UserFeatureWhitelistModel
WhitelistOrderModel model.WhitelistOrderModel
WhitelistOrderItemModel model.WhitelistOrderItemModel
QueryModel model.QueryModel
FeatureModel model.FeatureModel
}
// NewWhitelistService 创建白名单服务
func NewWhitelistService(
c config.Config,
userFeatureWhitelistModel model.UserFeatureWhitelistModel,
whitelistOrderModel model.WhitelistOrderModel,
whitelistOrderItemModel model.WhitelistOrderItemModel,
queryModel model.QueryModel,
featureModel model.FeatureModel,
) *WhitelistService {
return &WhitelistService{
config: c,
UserFeatureWhitelistModel: userFeatureWhitelistModel,
WhitelistOrderModel: whitelistOrderModel,
WhitelistOrderItemModel: whitelistOrderItemModel,
QueryModel: queryModel,
FeatureModel: featureModel,
}
}
// EnsureFreeWhitelist 免费下架:如果还没有生效白名单,则创建一条免费白名单记录
func (s *WhitelistService) EnsureFreeWhitelist(
ctx context.Context,
session sqlx.Session,
idCard string,
feature *model.Feature,
userId string,
orderId string,
) error {
builder := s.UserFeatureWhitelistModel.SelectBuilder().
Where("id_card = ? AND feature_id = ?", idCard, feature.Id)
records, err := s.UserFeatureWhitelistModel.FindAll(ctx, builder, "")
if err != nil {
return errors.Wrap(err, "查询白名单记录失败")
}
for _, r := range records {
if r.Status == 1 {
return nil
}
}
wl := &model.UserFeatureWhitelist{
Id: uuid.NewString(),
IdCard: idCard,
FeatureId: feature.Id,
FeatureApiId: feature.ApiId,
UserId: userId,
OrderId: lzUtils.StringToNullString(orderId),
WhitelistOrderId: lzUtils.StringToNullString(""),
Amount: 0,
Status: 1,
}
_, err = s.UserFeatureWhitelistModel.Insert(ctx, session, wl)
if err != nil {
return errors.Wrap(err, "创建免费白名单记录失败")
}
return nil
}
// CreateWhitelistByPaidOrder 根据已支付的白名单订单,创建对应的白名单记录
func (s *WhitelistService) CreateWhitelistByPaidOrder(
ctx context.Context,
session sqlx.Session,
order *model.Order,
whitelistOrder *model.WhitelistOrder,
) error {
if whitelistOrder.Status != 2 {
return nil
}
itemBuilder := s.WhitelistOrderItemModel.SelectBuilder().
Where("order_id = ?", whitelistOrder.Id)
items, err := s.WhitelistOrderItemModel.FindAll(ctx, itemBuilder, "")
if err != nil {
return errors.Wrap(err, "查询白名单订单明细失败")
}
for _, item := range items {
wl := &model.UserFeatureWhitelist{
Id: uuid.NewString(),
IdCard: whitelistOrder.IdCard,
FeatureId: item.FeatureId,
FeatureApiId: item.FeatureApiId,
UserId: whitelistOrder.UserId,
OrderId: lzUtils.StringToNullString(order.Id),
WhitelistOrderId: lzUtils.StringToNullString(whitelistOrder.Id),
Amount: item.Price,
Status: 1,
}
if _, err := s.UserFeatureWhitelistModel.Insert(ctx, session, wl); err != nil {
return errors.Wrap(err, "创建白名单记录失败")
}
}
return nil
}
// GetWhitelistedFeatureApisByIdCard 获取某个身份证号已下架的 feature_api_id 集合
func (s *WhitelistService) GetWhitelistedFeatureApisByIdCard(
ctx context.Context,
idCard string,
) (map[string]bool, error) {
result := make(map[string]bool)
if s == nil || idCard == "" {
return result, nil
}
builder := s.UserFeatureWhitelistModel.SelectBuilder().
Where("id_card = ? AND status = ?", idCard, 1)
list, err := s.UserFeatureWhitelistModel.FindAll(ctx, builder, "")
if err != nil {
return nil, errors.Wrap(err, "查询白名单失败")
}
for _, wl := range list {
result[wl.FeatureApiId] = true
}
return result, nil
}
// CheckWhitelistExists 检查指定身份证号和模块是否已有生效的白名单记录
func (s *WhitelistService) CheckWhitelistExists(
ctx context.Context,
idCard string,
featureId string,
) (bool, error) {
if idCard == "" || featureId == "" {
return false, nil
}
builder := s.UserFeatureWhitelistModel.SelectBuilder().
Where("id_card = ? AND feature_id = ? AND status = ?", idCard, featureId, 1)
list, err := s.UserFeatureWhitelistModel.FindAll(ctx, builder, "")
if err != nil {
return false, errors.Wrap(err, "查询白名单记录失败")
}
return len(list) > 0, nil
}
// ProcessOfflineFeature 统一下架处理
func (s *WhitelistService) ProcessOfflineFeature(
ctx context.Context,
session sqlx.Session,
idCard string,
featureApiId string,
userId string,
orderId string,
) (needPay bool, amount float64, whitelistCreated bool, err error) {
mainApiId := s.extractMainApiId(featureApiId)
feature, err := s.getFeatureByApiId(ctx, mainApiId)
if err != nil {
return false, 0, false, err
}
if feature.WhitelistPrice < 0 {
return false, 0, false, errors.Wrapf(xerr.NewErrMsg("该模块不支持下架"), "")
}
exists, err := s.CheckWhitelistExists(ctx, idCard, feature.Id)
if err != nil {
return false, 0, false, err
}
if exists {
return false, 0, true, nil
}
price := feature.WhitelistPrice
if price <= 0 {
if err := s.EnsureFreeWhitelist(ctx, session, idCard, feature, userId, orderId); err != nil {
return false, 0, false, err
}
return false, 0, true, nil
}
paidOrderId, err := s.findPaidWhitelistOrder(ctx, userId, idCard, feature.Id)
if err != nil {
return false, 0, false, err
}
if paidOrderId != "" {
if err := s.createWhitelistFromPaidOrder(ctx, session, idCard, feature, userId, orderId, paidOrderId, price); err != nil {
return false, 0, false, err
}
return false, price, true, nil
}
return true, price, false, nil
}
func (s *WhitelistService) extractMainApiId(featureApiId string) string {
if idx := strings.Index(featureApiId, "_"); idx > 0 {
return featureApiId[:idx]
}
return featureApiId
}
func (s *WhitelistService) getFeatureByApiId(ctx context.Context, apiId string) (*model.Feature, error) {
feature, err := s.FeatureModel.FindOneByApiId(ctx, apiId)
if err != nil {
if errors.Is(err, model.ErrNotFound) {
return nil, errors.Wrap(err, "模块不存在")
}
return nil, errors.Wrap(err, "查询模块信息失败")
}
return feature, nil
}
func (s *WhitelistService) findPaidWhitelistOrder(
ctx context.Context,
userId string,
idCard string,
featureId string,
) (string, error) {
orderBuilder := s.WhitelistOrderModel.SelectBuilder().
Where("user_id = ? AND id_card = ? AND status = ?", userId, idCard, 2)
orders, err := s.WhitelistOrderModel.FindAll(ctx, orderBuilder, "")
if err != nil {
return "", errors.Wrap(err, "查询白名单订单失败")
}
for _, order := range orders {
itemBuilder := s.WhitelistOrderItemModel.SelectBuilder().
Where("order_id = ? AND feature_id = ?", order.Id, featureId)
items, itemErr := s.WhitelistOrderItemModel.FindAll(ctx, itemBuilder, "")
if itemErr != nil {
return "", errors.Wrap(itemErr, "查询白名单订单明细失败")
}
if len(items) > 0 {
return order.Id, nil
}
}
return "", nil
}
func (s *WhitelistService) createWhitelistFromPaidOrder(
ctx context.Context,
session sqlx.Session,
idCard string,
feature *model.Feature,
userId string,
orderId string,
paidOrderId string,
price float64,
) error {
wl := &model.UserFeatureWhitelist{
Id: uuid.NewString(),
IdCard: idCard,
FeatureId: feature.Id,
FeatureApiId: feature.ApiId,
UserId: userId,
OrderId: lzUtils.StringToNullString(orderId),
WhitelistOrderId: lzUtils.StringToNullString(paidOrderId),
Amount: price,
Status: 1,
}
if _, err := s.UserFeatureWhitelistModel.Insert(ctx, session, wl); err != nil {
return errors.Wrap(err, "根据已支付订单创建白名单记录失败")
}
return nil
}
// DeleteFeatureFromQueryData 从报告数据中删除指定模块的数据
func (s *WhitelistService) DeleteFeatureFromQueryData(
ctx context.Context,
session sqlx.Session,
queryId string,
featureApiId string,
) error {
queryModel, err := s.getQueryModel(ctx, queryId)
if err != nil {
return err
}
if queryModel == nil {
return nil
}
mainApiId := s.extractMainApiId(featureApiId)
dataArray, key, err := s.decryptQueryData(queryModel)
if err != nil {
return err
}
modifiedArray, hasModified := s.clearFeatureData(dataArray, mainApiId)
if !hasModified {
logx.Infof("删除报告数据:查询记录 %s 中未找到模块 %s 的数据,跳过删除", queryId, featureApiId)
return nil
}
if err := s.updateQueryData(ctx, session, queryModel, modifiedArray, key); err != nil {
return err
}
return nil
}
func (s *WhitelistService) getQueryModel(ctx context.Context, queryId string) (*model.Query, error) {
queryModel, err := s.QueryModel.FindOne(ctx, queryId)
if err != nil {
if errors.Is(err, model.ErrNotFound) {
return nil, nil
}
return nil, errors.Wrap(err, "查询报告记录失败")
}
if !queryModel.QueryData.Valid || queryModel.QueryData.String == "" {
return nil, nil
}
return queryModel, nil
}
func (s *WhitelistService) decryptQueryData(queryModel *model.Query) ([]map[string]interface{}, []byte, error) {
secretKey := s.config.Encrypt.SecretKey
key, decodeErr := hex.DecodeString(secretKey)
if decodeErr != nil {
return nil, nil, errors.Wrap(decodeErr, "获取AES密钥失败")
}
decryptedData, decryptErr := crypto.AesDecrypt(queryModel.QueryData.String, key)
if decryptErr != nil {
return nil, nil, errors.Wrap(decryptErr, "解密报告数据失败")
}
var dataArray []map[string]interface{}
if unmarshalErr := json.Unmarshal(decryptedData, &dataArray); unmarshalErr != nil {
return nil, nil, errors.Wrap(unmarshalErr, "解析报告数据失败")
}
return dataArray, key, nil
}
func (s *WhitelistService) clearFeatureData(dataArray []map[string]interface{}, mainApiId string) ([]map[string]interface{}, bool) {
modifiedArray := make([]map[string]interface{}, 0, len(dataArray))
hasModified := false
for _, item := range dataArray {
newItem := make(map[string]interface{})
for k, v := range item {
newItem[k] = v
}
apiID, ok := item["apiID"].(string)
if !ok {
modifiedArray = append(modifiedArray, newItem)
continue
}
if s.extractMainApiId(apiID) == mainApiId {
newItem["data"] = nil
hasModified = true
}
modifiedArray = append(modifiedArray, newItem)
}
return modifiedArray, hasModified
}
func (s *WhitelistService) updateQueryData(
ctx context.Context,
session sqlx.Session,
queryModel *model.Query,
filteredArray []map[string]interface{},
key []byte,
) error {
filteredBytes, marshalErr := json.Marshal(filteredArray)
if marshalErr != nil {
return errors.Wrap(marshalErr, "序列化过滤后的报告数据失败")
}
encryptedData, encryptErr := crypto.AesEncrypt(filteredBytes, key)
if encryptErr != nil {
return errors.Wrap(encryptErr, "加密过滤后的报告数据失败")
}
queryModel.QueryData = sql.NullString{String: encryptedData, Valid: true}
if updateErr := s.QueryModel.UpdateWithVersion(ctx, session, queryModel); updateErr != nil {
return errors.Wrap(updateErr, "更新报告数据失败")
}
return nil
}
// CheckQueryDataContainsFeature 检查报告数据中是否包含指定的模块
func (s *WhitelistService) CheckQueryDataContainsFeature(
ctx context.Context,
queryId string,
featureApiId string,
) (bool, error) {
queryModel, err := s.getQueryModel(ctx, queryId)
if err != nil {
return false, err
}
if queryModel == nil {
return false, nil
}
mainApiId := s.extractMainApiId(featureApiId)
dataArray, _, err := s.decryptQueryData(queryModel)
if err != nil {
return false, err
}
for _, item := range dataArray {
apiID, ok := item["apiID"].(string)
if !ok {
continue
}
if s.extractMainApiId(apiID) == mainApiId {
dataValue, exists := item["data"]
if !exists || dataValue == nil {
return false, nil
}
return true, nil
}
}
return false, nil
}
// ProcessPaidWhitelistOrder 处理已支付的白名单订单
func (s *WhitelistService) ProcessPaidWhitelistOrder(
ctx context.Context,
session sqlx.Session,
order *model.Order,
whitelistOrder *model.WhitelistOrder,
) error {
if whitelistOrder.Status != 2 {
return nil
}
itemBuilder := s.WhitelistOrderItemModel.SelectBuilder().
Where("order_id = ?", whitelistOrder.Id)
items, err := s.WhitelistOrderItemModel.FindAll(ctx, itemBuilder, "")
if err != nil {
return errors.Wrap(err, "查询白名单订单明细失败")
}
for _, item := range items {
wl := &model.UserFeatureWhitelist{
Id: uuid.NewString(),
IdCard: whitelistOrder.IdCard,
FeatureId: item.FeatureId,
FeatureApiId: item.FeatureApiId,
UserId: whitelistOrder.UserId,
OrderId: lzUtils.StringToNullString(""),
WhitelistOrderId: lzUtils.StringToNullString(whitelistOrder.Id),
Amount: item.Price,
Status: 1,
}
if _, err := s.UserFeatureWhitelistModel.Insert(ctx, session, wl); err != nil {
return errors.Wrap(err, "创建白名单记录失败")
}
logx.Infof("白名单订单支付成功:订单 %s模块 %s已创建白名单记录", whitelistOrder.OrderNo, item.FeatureApiId)
}
return nil
}

View File

@@ -34,6 +34,11 @@ type ServiceContext struct {
FeatureModel model.FeatureModel
ProductFeatureModel model.ProductFeatureModel
// 白名单相关模型
UserFeatureWhitelistModel model.UserFeatureWhitelistModel
WhitelistOrderModel model.WhitelistOrderModel
WhitelistOrderItemModel model.WhitelistOrderItemModel
// 订单相关模型
OrderModel model.OrderModel
OrderRefundModel model.OrderRefundModel
@@ -77,11 +82,15 @@ type ServiceContext struct {
GlobalNotificationsModel model.GlobalNotificationsModel
AuthorizationDocumentModel model.AuthorizationDocumentModel
// 第三方服务
TianyuanapiCallLogService *service.TianyuanapiCallLogService
// 服务
AlipayService *service.AliPayService
WechatPayService *service.WechatPayService
ApplePayService *service.ApplePayService
ApiRequestService *service.ApiRequestService
WhitelistService *service.WhitelistService
AsynqServer *asynq.Server
AsynqService *service.AsynqService
VerificationService *service.VerificationService
@@ -152,10 +161,16 @@ func NewServiceContext(c config.Config) *ServiceContext {
adminDictDataModel := model.NewAdminDictDataModel(db, cacheConf)
adminDictTypeModel := model.NewAdminDictTypeModel(db, cacheConf)
// ============================== 白名单相关模型 ==============================
userFeatureWhitelistModel := model.NewUserFeatureWhitelistModel(db, cacheConf)
whitelistOrderModel := model.NewWhitelistOrderModel(db, cacheConf)
whitelistOrderItemModel := model.NewWhitelistOrderItemModel(db, cacheConf)
// ============================== 其他模型 ==============================
exampleModel := model.NewExampleModel(db, cacheConf)
globalNotificationsModel := model.NewGlobalNotificationsModel(db, cacheConf)
authorizationDocumentModel := model.NewAuthorizationDocumentModel(db, cacheConf)
tianyuanapiCallLogModel := model.NewTianyuanapiCallLogModel(db, cacheConf)
// ============================== 第三方服务初始化 ==============================
tianyuanapi, err := tianyuanapi.NewClient(tianyuanapi.Config{
@@ -172,7 +187,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
alipayService := service.NewAliPayService(c)
wechatPayService := service.NewWechatPayService(c, userAuthModel, service.InitTypeWxPayPubKey)
applePayService := service.NewApplePayService(c)
apiRequestService := service.NewApiRequestService(c, featureModel, productFeatureModel, tianyuanapi)
tianyuanapiCallLogService := service.NewTianyuanapiCallLogService(tianyuanapiCallLogModel, featureModel)
whitelistService := service.NewWhitelistService(c, userFeatureWhitelistModel, whitelistOrderModel, whitelistOrderItemModel, queryModel, featureModel)
apiRequestService := service.NewApiRequestService(c, featureModel, productFeatureModel, userFeatureWhitelistModel, tianyuanapi, tianyuanapiCallLogService, whitelistService)
verificationService := service.NewVerificationService(c, tianyuanapi, apiRequestService)
asynqService := service.NewAsynqService(c)
agentService := service.NewAgentService(c, orderModel, agentModel, agentWalletModel,
@@ -214,6 +231,11 @@ func NewServiceContext(c config.Config) *ServiceContext {
FeatureModel: featureModel,
ProductFeatureModel: productFeatureModel,
// 白名单相关模型
UserFeatureWhitelistModel: userFeatureWhitelistModel,
WhitelistOrderModel: whitelistOrderModel,
WhitelistOrderItemModel: whitelistOrderItemModel,
// 订单相关模型
OrderModel: orderModel,
QueryModel: queryModel,
@@ -257,11 +279,15 @@ func NewServiceContext(c config.Config) *ServiceContext {
GlobalNotificationsModel: globalNotificationsModel,
AuthorizationDocumentModel: authorizationDocumentModel,
// 第三方服务
TianyuanapiCallLogService: tianyuanapiCallLogService,
// 服务
AlipayService: alipayService,
WechatPayService: wechatPayService,
ApplePayService: applePayService,
ApiRequestService: apiRequestService,
WhitelistService: whitelistService,
AsynqServer: asynqServer,
AsynqService: asynqService,
VerificationService: verificationService,

View File

@@ -1,213 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminAuditAgentReq struct {
AuditId int64 `json:"audit_id"` // 审核记录ID
Status int64 `json:"status"` // 审核状态1=通过2=拒绝
AuditReason string `json:"audit_reason"` // 审核原因(拒绝时必填)
}
type AdminAuditAgentResp struct {
Success bool `json:"success"`
}
type AdminAuditWithdrawalReq struct {
WithdrawalId string `json:"withdrawal_id"` // 提现记录ID
Status int64 `json:"status"` // 审核状态2=通过3=拒绝
Remark string `json:"remark"` // 备注
}
type AdminAuditWithdrawalResp struct {
Success bool `json:"success"`
}
type AdminGenerateDiamondInviteCodeReq struct {
Count int64 `json:"count"` // 生成数量
ExpireDays int64 `json:"expire_days,optional"` // 过期天数可选0表示不过期
Remark string `json:"remark,optional"` // 备注(可选)
}
type AdminGenerateDiamondInviteCodeResp struct {
Codes []string `json:"codes"` // 生成的邀请码列表
}
type AdminGetAgentCommissionListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
AgentId *string `form:"agent_id,optional"` // 代理ID可选
OrderId *string `form:"order_id,optional"` // 订单ID可选
Status *int64 `form:"status,optional"` // 状态(可选)
}
type AdminGetAgentCommissionListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentCommissionListItem `json:"items"` // 列表数据
}
type AdminGetAgentConfigResp struct {
LevelBonus LevelBonusConfig `json:"level_bonus"` // 等级加成配置
UpgradeFee UpgradeFeeConfig `json:"upgrade_fee"` // 升级费用配置
UpgradeRebate UpgradeRebateConfig `json:"upgrade_rebate"` // 升级返佣配置
DirectParentRebate DirectParentRebateConfig `json:"direct_parent_rebate"` // 直接上级返佣配置
MaxGoldRebateAmount float64 `json:"max_gold_rebate_amount"` // 黄金代理最大返佣金额
CommissionFreeze CommissionFreezeConfig `json:"commission_freeze"` // 佣金冻结配置
TaxRate float64 `json:"tax_rate"` // 税率
TaxExemptionAmount float64 `json:"tax_exemption_amount"` // 免税额度
GoldMaxUpliftAmount float64 `json:"gold_max_uplift_amount"`
DiamondMaxUpliftAmount float64 `json:"diamond_max_uplift_amount"`
}
type AdminGetAgentLinkListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
AgentId *string `form:"agent_id,optional"` // 代理ID可选
ProductId *string `form:"product_id,optional"` // 产品ID可选
LinkIdentifier *string `form:"link_identifier,optional"` // 推广码(可选)
}
type AdminGetAgentLinkListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentLinkListItem `json:"items"` // 列表数据
}
type AdminGetAgentListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
Mobile *string `form:"mobile,optional"` // 手机号(可选)
Region *string `form:"region,optional"` // 区域(可选)
Level *int64 `form:"level,optional"` // 等级(可选)
TeamLeaderId *string `form:"team_leader_id,optional"` // 团队首领ID可选
}
type AdminGetAgentListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentListItem `json:"items"` // 列表数据
}
type AdminGetAgentOrderListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
AgentId *string `form:"agent_id,optional"` // 代理ID可选
OrderId *string `form:"order_id,optional"` // 订单ID可选
ProcessStatus *int64 `form:"process_status,optional"` // 处理状态(可选)
}
type AdminGetAgentOrderListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentOrderListItem `json:"items"` // 列表数据
}
type AdminGetAgentProductConfigListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
ProductId *string `form:"product_id,optional"` // 产品ID可选
ProductName *string `form:"product_name,optional"` // 产品名称(可选,用于搜索)
}
type AdminGetAgentProductConfigListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentProductConfigItem `json:"items"` // 列表数据
}
type AdminGetAgentRealNameListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
AgentId *string `form:"agent_id,optional"` // 代理ID可选
Status *int64 `form:"status,optional"` // 状态可选1=未验证2=已通过
}
type AdminGetAgentRealNameListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentRealNameListItem `json:"items"` // 列表数据
}
type AdminGetAgentRebateListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
AgentId *string `form:"agent_id,optional"` // 代理ID可选
SourceAgentId *string `form:"source_agent_id,optional"` // 来源代理ID可选
RebateType *int64 `form:"rebate_type,optional"` // 返佣类型(可选)
}
type AdminGetAgentRebateListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentRebateListItem `json:"items"` // 列表数据
}
type AdminGetAgentUpgradeListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
AgentId *string `form:"agent_id,optional"` // 代理ID可选
UpgradeType *int64 `form:"upgrade_type,optional"` // 升级类型(可选)
Status *int64 `form:"status,optional"` // 状态(可选)
}
type AdminGetAgentUpgradeListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentUpgradeListItem `json:"items"` // 列表数据
}
type AdminGetAgentWithdrawalListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
AgentId *string `form:"agent_id,optional"` // 代理ID可选
Status *int64 `form:"status,optional"` // 状态(可选)
WithdrawNo *string `form:"withdraw_no,optional"` // 提现单号(可选)
}
type AdminGetAgentWithdrawalListResp struct {
Total int64 `json:"total"` // 总数
Items []AgentWithdrawalListItem `json:"items"` // 列表数据
}
type AdminGetInviteCodeListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
Code *string `form:"code,optional"` // 邀请码(可选)
AgentId *string `form:"agent_id,optional"` // 发放代理ID可选NULL表示平台发放
TargetLevel *int64 `form:"target_level,optional"` // 目标等级(可选)
Status *int64 `form:"status,optional"` // 状态(可选)
}
type AdminGetInviteCodeListResp struct {
Total int64 `json:"total"` // 总数
Items []InviteCodeListItem `json:"items"` // 列表数据
}
type AdminUpdateAgentConfigReq struct {
LevelBonus *LevelBonusConfig `json:"level_bonus,optional"` // 等级加成配置
UpgradeFee *UpgradeFeeConfig `json:"upgrade_fee,optional"` // 升级费用配置
UpgradeRebate *UpgradeRebateConfig `json:"upgrade_rebate,optional"` // 升级返佣配置
DirectParentRebate *DirectParentRebateConfig `json:"direct_parent_rebate,optional"` // 直接上级返佣配置
MaxGoldRebateAmount *float64 `json:"max_gold_rebate_amount,optional"` // 黄金代理最大返佣金额
CommissionFreeze *CommissionFreezeConfig `json:"commission_freeze,optional"` // 佣金冻结配置
TaxRate *float64 `json:"tax_rate,optional"` // 税率
TaxExemptionAmount *float64 `json:"tax_exemption_amount,optional"` // 免税额度
GoldMaxUpliftAmount *float64 `json:"gold_max_uplift_amount,optional"`
DiamondMaxUpliftAmount *float64 `json:"diamond_max_uplift_amount,optional"`
}
type AdminUpdateAgentConfigResp struct {
Success bool `json:"success"`
}
type AdminUpdateAgentProductConfigReq struct {
Id string `json:"id"` // 主键
BasePrice float64 `json:"base_price"` // 基础底价
PriceRangeMax float64 `json:"price_range_max"` // 最高定价(对应数据库 system_max_price
PriceThreshold *float64 `json:"price_threshold,optional"` // 提价标准阈值(可选)
PriceFeeRate *float64 `json:"price_fee_rate,optional"` // 提价手续费比例(可选)
}
type AdminUpdateAgentProductConfigResp struct {
Success bool `json:"success"`
}
type AdminUpgradeAgentReq struct {
AgentId string `json:"agent_id"` // 代理ID
ToLevel int64 `json:"to_level"` // 目标等级2=黄金3=钻石
}
type AdminUpgradeAgentResp struct {
Success bool `json:"success"`
}

View File

@@ -1,67 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminBatchUpdateApiStatusReq struct {
Ids []string `json:"ids"`
Status int64 `json:"status"`
}
type AdminBatchUpdateApiStatusResp struct {
Success bool `json:"success"`
}
type AdminCreateApiReq struct {
ApiName string `json:"api_name"`
ApiCode string `json:"api_code"`
Method string `json:"method"`
Url string `json:"url"`
Status int64 `json:"status,default=1"`
Description string `json:"description,optional"`
}
type AdminCreateApiResp struct {
Id string `json:"id"`
}
type AdminDeleteApiReq struct {
Id string `path:"id"`
}
type AdminDeleteApiResp struct {
Success bool `json:"success"`
}
type AdminGetApiDetailReq struct {
Id string `path:"id"`
}
type AdminGetApiDetailResp struct {
AdminApiInfo
}
type AdminGetApiListReq struct {
Page int64 `form:"page,default=1"`
PageSize int64 `form:"page_size,default=20"`
ApiName string `form:"api_name,optional"`
Method string `form:"method,optional"`
Status int64 `form:"status,optional"`
}
type AdminGetApiListResp struct {
Items []AdminApiInfo `json:"items"`
Total int64 `json:"total"`
}
type AdminUpdateApiReq struct {
Id string `path:"id"`
ApiName string `json:"api_name"`
ApiCode string `json:"api_code"`
Method string `json:"method"`
Url string `json:"url"`
Status int64 `json:"status"`
Description string `json:"description,optional"`
}
type AdminUpdateApiResp struct {
Success bool `json:"success"`
}

View File

@@ -1,15 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminLoginReq struct {
Username string `json:"username" validate:"required"`
Password string `json:"password" validate:"required"`
Captcha bool `json:"captcha" validate:"required"`
}
type AdminLoginResp struct {
AccessToken string `json:"access_token"`
AccessExpire int64 `json:"access_expire"`
RefreshAfter int64 `json:"refresh_after"`
Roles []string `json:"roles"`
}

View File

@@ -1,75 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminConfigFeatureExampleReq struct {
FeatureId string `json:"feature_id"` // 功能ID
Data string `json:"data"` // 示例数据JSON
}
type AdminConfigFeatureExampleResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminCreateFeatureReq struct {
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
}
type AdminCreateFeatureResp struct {
Id string `json:"id"` // 功能ID
}
type AdminDeleteFeatureReq struct {
Id string `path:"id"` // 功能ID
}
type AdminDeleteFeatureResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminGetFeatureDetailReq struct {
Id string `path:"id"` // 功能ID
}
type AdminGetFeatureDetailResp struct {
Id string `json:"id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 描述
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type AdminGetFeatureExampleReq struct {
FeatureId string `path:"feature_id"` // 功能ID
}
type AdminGetFeatureExampleResp struct {
Id string `json:"id"` // 示例数据ID
FeatureId string `json:"feature_id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Data string `json:"data"` // 示例数据JSON
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type AdminGetFeatureListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
ApiId *string `form:"api_id,optional"` // API标识
Name *string `form:"name,optional"` // 描述
}
type AdminGetFeatureListResp struct {
Total int64 `json:"total"` // 总数
Items []FeatureListItem `json:"items"` // 列表数据
}
type AdminUpdateFeatureReq struct {
Id string `path:"id"` // 功能ID
ApiId *string `json:"api_id,optional"` // API标识
Name *string `json:"name,optional"` // 描述
}
type AdminUpdateFeatureResp struct {
Success bool `json:"success"` // 是否成功
}

View File

@@ -1,97 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type CreateMenuReq struct {
Pid string `json:"pid,optional"` // 父菜单ID
Name string `json:"name"` // 路由名称
Path string `json:"path,optional"` // 路由路径
Component string `json:"component,optional"` // 组件路径
Redirect string `json:"redirect,optional"` // 重定向路径
Meta map[string]interface{} `json:"meta"` // 路由元数据
Status int64 `json:"status,optional,default=1"` // 状态0-禁用1-启用
Type string `json:"type"` // 类型
Sort int64 `json:"sort,optional"` // 排序
}
type CreateMenuResp struct {
Id string `json:"id"` // 菜单ID
}
type DeleteMenuReq struct {
Id string `path:"id"` // 菜单ID
}
type DeleteMenuResp struct {
Success bool `json:"success"` // 是否成功
}
type GetMenuAllReq struct {
}
type GetMenuAllResp struct {
Name string `json:"name"`
Path string `json:"path"`
Redirect string `json:"redirect,omitempty"`
Component string `json:"component,omitempty"`
Sort int64 `json:"sort"`
Meta map[string]interface{} `json:"meta"`
Children []GetMenuAllResp `json:"children"`
}
type GetMenuDetailReq struct {
Id string `path:"id"` // 菜单ID
}
type GetMenuDetailResp struct {
Id string `json:"id"` // 菜单ID
Pid string `json:"pid"` // 父菜单ID
Name string `json:"name"` // 路由名称
Path string `json:"path"` // 路由路径
Component string `json:"component"` // 组件路径
Redirect string `json:"redirect"` // 重定向路径
Meta map[string]interface{} `json:"meta"` // 路由元数据
Status int64 `json:"status"` // 状态0-禁用1-启用
Type string `json:"type"` // 类型
Sort int64 `json:"sort"` // 排序
CreateTime string `json:"createTime"` // 创建时间
UpdateTime string `json:"updateTime"` // 更新时间
}
type GetMenuListReq struct {
Name string `form:"name,optional"` // 菜单名称
Path string `form:"path,optional"` // 路由路径
Status int64 `form:"status,optional,default=-1"` // 状态0-禁用1-启用
Type string `form:"type,optional"` // 类型
}
type MenuListItem struct {
Id string `json:"id"` // 菜单ID
Pid string `json:"pid"` // 父菜单ID
Name string `json:"name"` // 路由名称
Path string `json:"path"` // 路由路径
Component string `json:"component"` // 组件路径
Redirect string `json:"redirect"` // 重定向路径
Meta map[string]interface{} `json:"meta"` // 路由元数据
Status int64 `json:"status"` // 状态0-禁用1-启用
Type string `json:"type"` // 类型
Sort int64 `json:"sort"` // 排序
CreateTime string `json:"createTime"` // 创建时间
Children []MenuListItem `json:"children"` // 子菜单
}
type UpdateMenuReq struct {
Id string `path:"id"` // 菜单ID
Pid *string `json:"pid,optional"` // 父菜单ID
Name string `json:"name"` // 路由名称
Path string `json:"path,optional"` // 路由路径
Component string `json:"component,optional"` // 组件路径
Redirect string `json:"redirect,optional"` // 重定向路径
Meta map[string]interface{} `json:"meta"` // 路由元数据
Status int64 `json:"status,optional"` // 状态0-禁用1-启用
Type string `json:"type"` // 类型
Sort int64 `json:"sort,optional"` // 排序
}
type UpdateMenuResp struct {
Success bool `json:"success"` // 是否成功
}

View File

@@ -1,74 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminCreateNotificationReq struct {
Title string `json:"title"` // 通知标题
NotificationPage string `json:"notification_page"` // 通知页面
Content string `json:"content"` // 通知内容
StartDate string `json:"start_date"` // 生效开始日期yyyy-MM-dd
StartTime string `json:"start_time"` // 生效开始时间HH:mm:ss
EndDate string `json:"end_date"` // 生效结束日期yyyy-MM-dd
EndTime string `json:"end_time"` // 生效结束时间HH:mm:ss
Status int64 `json:"status"` // 状态1-启用0-禁用
}
type AdminCreateNotificationResp struct {
Id string `json:"id"` // 通知ID
}
type AdminDeleteNotificationReq struct {
Id string `path:"id"` // 通知ID
}
type AdminDeleteNotificationResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminGetNotificationDetailReq struct {
Id string `path:"id"` // 通知ID
}
type AdminGetNotificationDetailResp struct {
Id string `json:"id"` // 通知ID
Title string `json:"title"` // 通知标题
Content string `json:"content"` // 通知内容
NotificationPage string `json:"notification_page"` // 通知页面
StartDate string `json:"start_date"` // 生效开始日期
StartTime string `json:"start_time"` // 生效开始时间
EndDate string `json:"end_date"` // 生效结束日期
EndTime string `json:"end_time"` // 生效结束时间
Status int64 `json:"status"` // 状态
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type AdminGetNotificationListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
Title *string `form:"title,optional"` // 通知标题(可选)
NotificationPage *string `form:"notification_page,optional"` // 通知页面(可选)
Status *int64 `form:"status,optional"` // 状态(可选)
StartDate *string `form:"start_date,optional"` // 开始日期范围(可选)
EndDate *string `form:"end_date,optional"` // 结束日期范围(可选)
}
type AdminGetNotificationListResp struct {
Total int64 `json:"total"` // 总数
Items []NotificationListItem `json:"items"` // 列表数据
}
type AdminUpdateNotificationReq struct {
Id string `path:"id"` // 通知ID
Title *string `json:"title,optional"` // 通知标题
Content *string `json:"content,optional"` // 通知内容
NotificationPage *string `json:"notification_page,optional"` // 通知页面
StartDate *string `json:"start_date,optional"` // 生效开始日期
StartTime *string `json:"start_time,optional"` // 生效开始时间
EndDate *string `json:"end_date,optional"` // 生效结束日期
EndTime *string `json:"end_time,optional"` // 生效结束时间
Status *int64 `json:"status,optional"` // 状态
}
type AdminUpdateNotificationResp struct {
Success bool `json:"success"` // 是否成功
}

View File

@@ -1,108 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminCreateOrderReq struct {
OrderNo string `json:"order_no"` // 商户订单号
PlatformOrderId string `json:"platform_order_id"` // 支付订单号
ProductName string `json:"product_name"` // 产品名称
PaymentPlatform string `json:"payment_platform"` // 支付方式
PaymentScene string `json:"payment_scene"` // 支付平台
Amount float64 `json:"amount"` // 金额
Status string `json:"status,default=pending"` // 支付状态pending-待支付paid-已支付refunded-已退款closed-已关闭failed-支付失败
}
type AdminCreateOrderResp struct {
Id string `json:"id"` // 订单ID
}
type AdminDeleteOrderReq struct {
Id string `path:"id"` // 订单ID
}
type AdminDeleteOrderResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminGetOrderDetailReq struct {
Id string `path:"id"` // 订单ID
}
type AdminGetOrderDetailResp struct {
Id string `json:"id"` // 订单ID
OrderNo string `json:"order_no"` // 商户订单号
PlatformOrderId string `json:"platform_order_id"` // 支付订单号
ProductName string `json:"product_name"` // 产品名称
PaymentPlatform string `json:"payment_platform"` // 支付方式
PaymentScene string `json:"payment_scene"` // 支付平台
Amount float64 `json:"amount"` // 金额
Status string `json:"status"` // 支付状态pending-待支付paid-已支付refunded-已退款closed-已关闭failed-支付失败
QueryState string `json:"query_state"` // 查询状态pending-待查询success-查询成功failed-查询失败 processing-查询中
CreateTime string `json:"create_time"` // 创建时间
PayTime string `json:"pay_time"` // 支付时间
RefundTime string `json:"refund_time"` // 退款时间
UpdateTime string `json:"update_time"` // 更新时间
IsAgentOrder bool `json:"is_agent_order"` // 是否是代理订单
AgentProcessStatus string `json:"agent_process_status"` // 代理事务处理状态not_agent-非代理订单success-处理成功failed-处理失败pending-待处理
}
type AdminGetOrderListReq struct {
Page int64 `form:"page,default=1"` // 页码
PageSize int64 `form:"pageSize,default=20"` // 每页数量
OrderNo string `form:"order_no,optional"` // 商户订单号
PlatformOrderId string `form:"platform_order_id,optional"` // 支付订单号
ProductName string `form:"product_name,optional"` // 产品名称
PaymentPlatform string `form:"payment_platform,optional"` // 支付方式
PaymentScene string `form:"payment_scene,optional"` // 支付平台
Amount float64 `form:"amount,optional"` // 金额
Status string `form:"status,optional"` // 支付状态pending-待支付paid-已支付refunded-已退款closed-已关闭failed-支付失败
CreateTimeStart string `form:"create_time_start,optional"` // 创建时间开始
CreateTimeEnd string `form:"create_time_end,optional"` // 创建时间结束
PayTimeStart string `form:"pay_time_start,optional"` // 支付时间开始
PayTimeEnd string `form:"pay_time_end,optional"` // 支付时间结束
RefundTimeStart string `form:"refund_time_start,optional"` // 退款时间开始
RefundTimeEnd string `form:"refund_time_end,optional"` // 退款时间结束
}
type AdminGetOrderListResp struct {
Total int64 `json:"total"` // 总数
Items []OrderListItem `json:"items"` // 列表
}
type AdminRefundOrderReq struct {
Id string `path:"id"` // 订单ID
RefundAmount float64 `json:"refund_amount"` // 退款金额
RefundReason string `json:"refund_reason"` // 退款原因
}
type AdminRefundOrderResp struct {
Status string `json:"status"` // 退款状态
RefundNo string `json:"refund_no"` // 退款单号
Amount float64 `json:"amount"` // 退款金额
}
type AdminRetryAgentProcessReq struct {
Id string `path:"id"` // 订单ID
}
type AdminRetryAgentProcessResp struct {
Status string `json:"status"` // 执行状态success-成功already_processed-已处理failed-失败
Message string `json:"message"` // 执行结果消息
ProcessedAt string `json:"processed_at"` // 处理时间
}
type AdminUpdateOrderReq struct {
Id string `path:"id"` // 订单ID
OrderNo *string `json:"order_no,optional"` // 商户订单号
PlatformOrderId *string `json:"platform_order_id,optional"` // 支付订单号
ProductName *string `json:"product_name,optional"` // 产品名称
PaymentPlatform *string `json:"payment_platform,optional"` // 支付方式
PaymentScene *string `json:"payment_scene,optional"` // 支付平台
Amount *float64 `json:"amount,optional"` // 金额
Status *string `json:"status,optional"` // 支付状态pending-待支付paid-已支付refunded-已退款closed-已关闭failed-支付失败
PayTime *string `json:"pay_time,optional"` // 支付时间
RefundTime *string `json:"refund_time,optional"` // 退款时间
}
type AdminUpdateOrderResp struct {
Success bool `json:"success"` // 是否成功
}

View File

@@ -1,66 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminCreatePlatformUserReq struct {
Mobile string `json:"mobile"` // 手机号
Password string `json:"password"` // 密码
Nickname string `json:"nickname"` // 昵称
Info string `json:"info"` // 备注信息
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
}
type AdminCreatePlatformUserResp struct {
Id string `json:"id"` // 用户ID
}
type AdminDeletePlatformUserReq struct {
Id string `path:"id"` // 用户ID
}
type AdminDeletePlatformUserResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminGetPlatformUserDetailReq struct {
Id string `path:"id"` // 用户ID
}
type AdminGetPlatformUserDetailResp struct {
Id string `json:"id"` // 用户ID
Mobile string `json:"mobile"` // 手机号
Nickname string `json:"nickname"` // 昵称
Info string `json:"info"` // 备注信息
Inside int64 `json:"inside"` // 是否内部用户 1-是 0-否
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type AdminGetPlatformUserListReq struct {
Page int64 `form:"page,default=1"` // 页码
PageSize int64 `form:"pageSize,default=20"` // 每页数量
Mobile string `form:"mobile,optional"` // 手机号
Nickname string `form:"nickname,optional"` // 昵称
Inside int64 `form:"inside,optional"` // 是否内部用户 1-是 0-否
CreateTimeStart string `form:"create_time_start,optional"` // 创建时间开始
CreateTimeEnd string `form:"create_time_end,optional"` // 创建时间结束
OrderBy string `form:"order_by,optional"` // 排序字段
OrderType string `form:"order_type,optional"` // 排序类型
}
type AdminGetPlatformUserListResp struct {
Total int64 `json:"total"` // 总数
Items []PlatformUserListItem `json:"items"` // 列表
}
type AdminUpdatePlatformUserReq struct {
Id string `path:"id"` // 用户ID
Mobile *string `json:"mobile,optional"` // 手机号
Password *string `json:"password,optional"` // 密码
Nickname *string `json:"nickname,optional"` // 昵称
Info *string `json:"info,optional"` // 备注信息
Inside *int64 `json:"inside,optional"` // 是否内部用户 1-是 0-否
}
type AdminUpdatePlatformUserResp struct {
Success bool `json:"success"` // 是否成功
}

View File

@@ -1,91 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminCreateProductReq struct {
ProductName string `json:"product_name"` // 服务名
ProductEn string `json:"product_en"` // 英文名
Description string `json:"description"` // 描述
Notes string `json:"notes,optional"` // 备注
CostPrice float64 `json:"cost_price"` // 成本
SellPrice float64 `json:"sell_price"` // 售价
}
type AdminCreateProductResp struct {
Id string `json:"id"` // 产品ID
}
type AdminDeleteProductReq struct {
Id string `path:"id"` // 产品ID
}
type AdminDeleteProductResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminGetProductDetailReq struct {
Id string `path:"id"` // 产品ID
}
type AdminGetProductDetailResp struct {
Id string `json:"id"` // 产品ID
ProductName string `json:"product_name"` // 服务名
ProductEn string `json:"product_en"` // 英文名
Description string `json:"description"` // 描述
Notes string `json:"notes"` // 备注
CostPrice float64 `json:"cost_price"` // 成本
SellPrice float64 `json:"sell_price"` // 售价
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type AdminGetProductFeatureListReq struct {
ProductId string `path:"product_id"` // 产品ID
}
type AdminGetProductFeatureListResp struct {
Id string `json:"id"` // 关联ID
ProductId string `json:"product_id"` // 产品ID
FeatureId string `json:"feature_id"` // 功能ID
ApiId string `json:"api_id"` // API标识
Name string `json:"name"` // 功能描述
Sort int64 `json:"sort"` // 排序
Enable int64 `json:"enable"` // 是否启用
IsImportant int64 `json:"is_important"` // 是否重要
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
}
type AdminGetProductListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"pageSize"` // 每页数量
ProductName *string `form:"product_name,optional"` // 服务名
ProductEn *string `form:"product_en,optional"` // 英文名
}
type AdminGetProductListResp struct {
Total int64 `json:"total"` // 总数
Items []ProductListItem `json:"items"` // 列表数据
}
type AdminUpdateProductFeaturesReq struct {
ProductId string `path:"product_id"` // 产品ID
Features []ProductFeatureItem `json:"features"` // 功能列表
}
type AdminUpdateProductFeaturesResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminUpdateProductReq struct {
Id string `path:"id"` // 产品ID
ProductName *string `json:"product_name,optional"` // 服务名
ProductEn *string `json:"product_en,optional"` // 英文名
Description *string `json:"description,optional"` // 描述
Notes *string `json:"notes,optional"` // 备注
CostPrice *float64 `json:"cost_price,optional"` // 成本
SellPrice *float64 `json:"sell_price,optional"` // 售价
}
type AdminUpdateProductResp struct {
Success bool `json:"success"` // 是否成功
}

View File

@@ -1,60 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminGetQueryCleanupConfigListReq struct {
Status int64 `form:"status,optional"` // 状态1-启用0-禁用
}
type AdminGetQueryCleanupConfigListResp struct {
Items []QueryCleanupConfigItem `json:"items"` // 配置列表
}
type AdminGetQueryCleanupDetailListReq struct {
LogId string `path:"log_id"` // 清理日志ID
Page int64 `form:"page,default=1"` // 页码
PageSize int64 `form:"page_size,default=20"` // 每页数量
}
type AdminGetQueryCleanupDetailListResp struct {
Total int64 `json:"total"` // 总数
Items []QueryCleanupDetailItem `json:"items"` // 列表
}
type AdminGetQueryCleanupLogListReq struct {
Page int64 `form:"page,default=1"` // 页码
PageSize int64 `form:"page_size,default=20"` // 每页数量
Status int64 `form:"status,optional"` // 状态1-成功2-失败
StartTime string `form:"start_time,optional"` // 开始时间
EndTime string `form:"end_time,optional"` // 结束时间
}
type AdminGetQueryCleanupLogListResp struct {
Total int64 `json:"total"` // 总数
Items []QueryCleanupLogItem `json:"items"` // 列表
}
type AdminGetQueryDetailByOrderIdReq struct {
OrderId string `path:"order_id"`
}
type AdminGetQueryDetailByOrderIdResp struct {
Id string `json:"id"` // 主键ID
OrderId string `json:"order_id"` // 订单ID
UserId string `json:"user_id"` // 用户ID
ProductName string `json:"product_name"` // 产品ID
QueryParams map[string]interface{} `json:"query_params"`
QueryData []AdminQueryItem `json:"query_data"`
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
QueryState string `json:"query_state"` // 查询状态
}
type AdminUpdateQueryCleanupConfigReq struct {
Id string `json:"id"` // 主键ID
ConfigValue string `json:"config_value"` // 配置值
Status int64 `json:"status"` // 状态1-启用0-禁用
}
type AdminUpdateQueryCleanupConfigResp struct {
Success bool `json:"success"` // 是否成功
}

View File

@@ -1,66 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type CreateRoleReq struct {
RoleName string `json:"role_name"` // 角色名称
RoleCode string `json:"role_code"` // 角色编码
Description string `json:"description"` // 角色描述
Status int64 `json:"status,default=1"` // 状态0-禁用1-启用
Sort int64 `json:"sort,default=0"` // 排序
MenuIds []string `json:"menu_ids"` // 关联的菜单ID列表
}
type CreateRoleResp struct {
Id string `json:"id"` // 角色ID
}
type DeleteRoleReq struct {
Id string `path:"id"` // 角色ID
}
type DeleteRoleResp struct {
Success bool `json:"success"` // 是否成功
}
type GetRoleDetailReq struct {
Id string `path:"id"` // 角色ID
}
type GetRoleDetailResp struct {
Id string `json:"id"` // 角色ID
RoleName string `json:"role_name"` // 角色名称
RoleCode string `json:"role_code"` // 角色编码
Description string `json:"description"` // 角色描述
Status int64 `json:"status"` // 状态0-禁用1-启用
Sort int64 `json:"sort"` // 排序
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
MenuIds []string `json:"menu_ids"` // 关联的菜单ID列表
}
type GetRoleListReq struct {
Page int64 `form:"page,default=1"` // 页码
PageSize int64 `form:"pageSize,default=20"` // 每页数量
Name string `form:"name,optional"` // 角色名称
Code string `form:"code,optional"` // 角色编码
Status int64 `form:"status,optional,default=-1"` // 状态0-禁用1-启用
}
type GetRoleListResp struct {
Total int64 `json:"total"` // 总数
Items []RoleListItem `json:"items"` // 列表
}
type UpdateRoleReq struct {
Id string `path:"id"` // 角色ID
RoleName *string `json:"role_name,optional"` // 角色名称
RoleCode *string `json:"role_code,optional"` // 角色编码
Description *string `json:"description,optional"` // 角色描述
Status *int64 `json:"status,optional"` // 状态0-禁用1-启用
Sort *int64 `json:"sort,optional"` // 排序
MenuIds []string `json:"menu_ids,optional"` // 关联的菜单ID列表
}
type UpdateRoleResp struct {
Success bool `json:"success"` // 是否成功
}

View File

@@ -1,45 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminAssignRoleApiReq struct {
RoleId string `json:"role_id"`
ApiIds []string `json:"api_ids"`
}
type AdminAssignRoleApiResp struct {
Success bool `json:"success"`
}
type AdminGetAllApiListReq struct {
Status int64 `form:"status,optional,default=1"`
}
type AdminGetAllApiListResp struct {
Items []AdminRoleApiInfo `json:"items"`
}
type AdminGetRoleApiListReq struct {
RoleId string `path:"role_id"`
}
type AdminGetRoleApiListResp struct {
Items []AdminRoleApiInfo `json:"items"`
}
type AdminRemoveRoleApiReq struct {
RoleId string `json:"role_id"`
ApiIds []string `json:"api_ids"`
}
type AdminRemoveRoleApiResp struct {
Success bool `json:"success"`
}
type AdminUpdateRoleApiReq struct {
RoleId string `json:"role_id"`
ApiIds []string `json:"api_ids"`
}
type AdminUpdateRoleApiResp struct {
Success bool `json:"success"`
}

View File

@@ -1,78 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AdminCreateUserReq struct {
Username string `json:"username"` // 用户名
RealName string `json:"real_name"` // 真实姓名
Status int64 `json:"status,default=1"` // 状态0-禁用1-启用
RoleIds []string `json:"role_ids"` // 关联的角色ID列表
}
type AdminCreateUserResp struct {
Id string `json:"id"` // 用户ID
}
type AdminDeleteUserReq struct {
Id string `path:"id"` // 用户ID
}
type AdminDeleteUserResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminGetUserDetailReq struct {
Id string `path:"id"` // 用户ID
}
type AdminGetUserDetailResp struct {
Id string `json:"id"` // 用户ID
Username string `json:"username"` // 用户名
RealName string `json:"real_name"` // 真实姓名
Status int64 `json:"status"` // 状态0-禁用1-启用
CreateTime string `json:"create_time"` // 创建时间
UpdateTime string `json:"update_time"` // 更新时间
RoleIds []string `json:"role_ids"` // 关联的角色ID列表
}
type AdminGetUserListReq struct {
Page int64 `form:"page,default=1"` // 页码
PageSize int64 `form:"pageSize,default=20"` // 每页数量
Username string `form:"username,optional"` // 用户名
RealName string `form:"real_name,optional"` // 真实姓名
Status int64 `form:"status,optional,default=-1"` // 状态0-禁用1-启用
}
type AdminGetUserListResp struct {
Total int64 `json:"total"` // 总数
Items []AdminUserListItem `json:"items"` // 列表
}
type AdminResetPasswordReq struct {
Id string `path:"id"` // 用户ID
Password string `json:"password"` // 新密码
}
type AdminResetPasswordResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminUpdateUserReq struct {
Id string `path:"id"` // 用户ID
Username *string `json:"username,optional"` // 用户名
RealName *string `json:"real_name,optional"` // 真实姓名
Status *int64 `json:"status,optional"` // 状态0-禁用1-启用
RoleIds []string `json:"role_ids,optional"` // 关联的角色ID列表
}
type AdminUpdateUserResp struct {
Success bool `json:"success"` // 是否成功
}
type AdminUserInfoReq struct {
}
type AdminUserInfoResp struct {
Username string `json:"username"` // 用户名
RealName string `json:"real_name"` // 真实姓名
Roles []string `json:"roles"` // 角色编码列表
}

View File

@@ -1,300 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AgentApplyReq struct {
Region string `json:"region,optional"`
Mobile string `json:"mobile"`
Code string `json:"code"`
Referrer string `json:"referrer"`
InviteCode string `json:"invite_code,optional"`
AgentCode int64 `json:"agent_code,optional"`
}
type AgentApplyResp struct {
AccessToken string `json:"accessToken"`
AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"`
AgentCode int64 `json:"agent_code"`
}
type AgentGeneratingLinkReq struct {
ProductId string `json:"product_id"` // 产品ID
SetPrice float64 `json:"set_price"` // 设定价格
TargetPath string `json:"target_path,optional"` // 目标地址(可选,默认为推广报告页面)
}
type AgentGeneratingLinkResp struct {
LinkIdentifier string `json:"link_identifier"` // 推广链接标识
FullLink string `json:"full_link"` // 完整短链URL
}
type AgentInfoResp struct {
AgentId string `json:"agent_id"`
Level int64 `json:"level"`
LevelName string `json:"level_name"`
Region string `json:"region"`
Mobile string `json:"mobile"`
WechatId string `json:"wechat_id"`
TeamLeaderId string `json:"team_leader_id"`
IsRealName bool `json:"is_real_name"`
AgentCode int64 `json:"agent_code"`
}
type AgentProductConfigResp struct {
List []ProductConfigItem `json:"list"`
}
type ApplyUpgradeReq struct {
ToLevel int64 `json:"to_level"` // 目标等级2=黄金3=钻石
}
type ApplyUpgradeResp struct {
UpgradeId string `json:"upgrade_id"` // 升级记录ID
OrderNo string `json:"order_no"` // 支付订单号
}
type ApplyWithdrawalReq struct {
Amount float64 `json:"amount"` // 提现金额
PayeeAccount string `json:"payee_account"` // 收款账户
PayeeName string `json:"payee_name"` // 收款人姓名
}
type ApplyWithdrawalResp struct {
WithdrawalId string `json:"withdrawal_id"` // 提现记录ID
WithdrawalNo string `json:"withdrawal_no"` // 提现单号
}
type ConversionRateResp struct {
MyConversionRate ConversionRateData `json:"my_conversion_rate"` // 我的转化率
SubordinateConversionRate ConversionRateData `json:"subordinate_conversion_rate"` // 我的下级转化率
}
type DeleteInviteCodeReq struct {
Id string `json:"id"` // 邀请码ID
}
type DeleteInviteCodeResp struct {
}
type GenerateInviteCodeReq struct {
Count int64 `json:"count"` // 生成数量
ExpireDays int64 `json:"expire_days,optional"` // 过期天数可选0表示不过期
Remark string `json:"remark,optional"` // 备注(可选)
}
type GenerateInviteCodeResp struct {
Codes []string `json:"codes"` // 生成的邀请码列表
}
type GetCommissionListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
}
type GetCommissionListResp struct {
Total int64 `json:"total"` // 总数
List []CommissionItem `json:"list"` // 列表
}
type GetInviteCodeListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
Status int64 `form:"status,optional"` // 状态(可选)
}
type GetInviteCodeListResp struct {
Total int64 `json:"total"` // 总数
List []InviteCodeItem `json:"list"` // 列表
}
type GetInviteLinkReq struct {
InviteCode string `form:"invite_code"` // 邀请码
TargetPath string `form:"target_path,optional"` // 目标地址(可选,默认为注册页面)
}
type GetInviteLinkResp struct {
InviteLink string `json:"invite_link"` // 邀请链接
}
type GetLevelPrivilegeResp struct {
Levels []LevelPrivilegeItem `json:"levels"`
UpgradeToGoldFee float64 `json:"upgrade_to_gold_fee"`
UpgradeToDiamondFee float64 `json:"upgrade_to_diamond_fee"`
UpgradeToGoldRebate float64 `json:"upgrade_to_gold_rebate"`
UpgradeToDiamondRebate float64 `json:"upgrade_to_diamond_rebate"`
}
type GetLinkDataReq struct {
LinkIdentifier string `form:"link_identifier"` // 推广链接标识
}
type GetLinkDataResp struct {
AgentId string `json:"agent_id"` // 代理ID
ProductId string `json:"product_id"` // 产品ID
SetPrice float64 `json:"set_price"` // 代理设定价格
ActualBasePrice float64 `json:"actual_base_price"` // 实际底价
ProductName string `json:"product_name"` // 产品名称
ProductEn string `json:"product_en"` // 产品英文标识
SellPrice float64 `json:"sell_price"` // 销售价格(使用代理设定价格)
Description string `json:"description"` // 产品描述
Features []Feature `json:"features"` // 产品功能列表
}
type GetPromotionQueryListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
}
type GetPromotionQueryListResp struct {
Total int64 `json:"total"` // 总数
List []PromotionQueryItem `json:"list"` // 列表
}
type GetRebateListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
RebateType *int64 `form:"rebate_type,optional"` // 返佣类型可选1=直接上级返佣2=钻石上级返佣3=黄金上级返佣
}
type GetRebateListResp struct {
Total int64 `json:"total"` // 总数
List []RebateItem `json:"list"` // 列表
}
type GetRevenueInfoResp struct {
Balance float64 `json:"balance"` // 可用余额
FrozenBalance float64 `json:"frozen_balance"` // 冻结余额
TotalEarnings float64 `json:"total_earnings"` // 累计收益(钱包总收益)
WithdrawnAmount float64 `json:"withdrawn_amount"` // 累计提现
CommissionTotal float64 `json:"commission_total"` // 佣金累计总收益(推广订单获得的佣金)
CommissionToday float64 `json:"commission_today"` // 佣金今日收益
CommissionMonth float64 `json:"commission_month"` // 佣金本月收益
RebateTotal float64 `json:"rebate_total"` // 返佣累计总收益(包括推广返佣和升级返佣)
RebateToday float64 `json:"rebate_today"` // 返佣今日收益
RebateMonth float64 `json:"rebate_month"` // 返佣本月收益
}
type GetSubordinateContributionDetailReq struct {
SubordinateId string `form:"subordinate_id"` // 下级代理ID
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
TabType string `form:"tab_type,optional"` // 标签页类型order=订单列表invite=邀请列表
}
type GetSubordinateContributionDetailResp struct {
Mobile string `json:"mobile"` // 手机号
LevelName string `json:"level_name"` // 等级名称
CreateTime string `json:"create_time"` // 创建时间
OrderStats OrderStatistics `json:"order_stats"` // 订单统计(仅统计有返佣的订单)
RebateStats RebateStatistics `json:"rebate_stats"` // 返佣统计
InviteStats InviteStatistics `json:"invite_stats"` // 邀请统计
OrderList []OrderItem `json:"order_list"` // 订单列表(仅有贡献的订单)
InviteList []InviteItem `json:"invite_list"` // 邀请列表
OrderListTotal int64 `json:"order_list_total"` // 订单列表总数
InviteListTotal int64 `json:"invite_list_total"` // 邀请列表总数
}
type GetSubordinateListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
}
type GetSubordinateListResp struct {
Total int64 `json:"total"` // 总数
List []SubordinateItem `json:"list"` // 列表
}
type GetTeamListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
Mobile string `form:"mobile,optional"` // 手机号(可选,用于搜索)
}
type GetTeamListResp struct {
Statistics TeamStatistics `json:"statistics"` // 统计数据
Total int64 `json:"total"` // 总数
List []TeamMemberItem `json:"list"` // 列表
}
type GetUpgradeListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
}
type GetUpgradeListResp struct {
Total int64 `json:"total"` // 总数
List []UpgradeItem `json:"list"` // 列表
}
type GetUpgradeRebateListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
}
type GetUpgradeRebateListResp struct {
Total int64 `json:"total"` // 总数
List []UpgradeRebateItem `json:"list"` // 列表
}
type GetWithdrawalListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数量
}
type GetWithdrawalListResp struct {
Total int64 `json:"total"` // 总数
List []WithdrawalItem `json:"list"` // 列表
}
type RealNameAuthReq struct {
Name string `json:"name"` // 姓名
IdCard string `json:"id_card"` // 身份证号
Mobile string `json:"mobile"` // 手机号
Code string `json:"code"` // 验证码
}
type RealNameAuthResp struct {
Status string `json:"status"` // 状态pending=待审核approved=已通过rejected=已拒绝
}
type RegisterByInviteCodeReq struct {
Referrer string `json:"referrer"`
InviteCode string `json:"invite_code,optional"`
AgentCode int64 `json:"agent_code,optional"`
Mobile string `json:"mobile"`
Code string `json:"code"`
Region string `json:"region,optional"`
WechatId string `json:"wechat_id,optional"`
}
type RegisterByInviteCodeResp struct {
AccessToken string `json:"accessToken"`
AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"`
AgentId string `json:"agent_id"` // 代理ID
Level int64 `json:"level"` // 代理等级
LevelName string `json:"level_name"` // 等级名称
AgentCode int64 `json:"agent_code"`
}
type ShortLinkRedirectResp struct {
}
type TeamStatisticsResp struct {
TotalCount int64 `json:"total_count"` // 团队总人数(不包括自己)
DirectCount int64 `json:"direct_count"` // 直接下级数量
IndirectCount int64 `json:"indirect_count"` // 间接下级数量
GoldCount int64 `json:"gold_count"` // 黄金代理数量
NormalCount int64 `json:"normal_count"` // 普通代理数量
TodayNewMembers int64 `json:"today_new_members"` // 今日新增成员
MonthNewMembers int64 `json:"month_new_members"` // 本月新增成员
}
type UpgradeSubordinateReq struct {
SubordinateId string `json:"subordinate_id"` // 下级代理ID
ToLevel int64 `json:"to_level"` // 目标等级只能是2=黄金)
}
type UpgradeSubordinateResp struct {
Success bool `json:"success"`
}

View File

@@ -1,16 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type HealthCheckResp struct {
Status string `json:"status"` // 服务状态
Message string `json:"message"` // 状态信息
}
type GetAppConfigResp struct {
QueryRetentionDays int64 `json:"query_retention_days"`
}
type GetAppVersionResp struct {
Version string `json:"version"`
WgtUrl string `json:"wgtUrl"`
}

View File

@@ -1,7 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type SendSmsReq struct {
Mobile string `json:"mobile" validate:"required,mobile"`
ActionType string `json:"actionType" validate:"required,oneof=login register query agentApply realName bindMobile"`
}

View File

@@ -1,36 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type DownloadAuthorizationDocumentReq struct {
DocumentId string `json:"documentId" validate:"required"` // 授权书ID
}
type DownloadAuthorizationDocumentResp struct {
FileName string `json:"fileName"` // 文件名
FileUrl string `json:"fileUrl"` // 文件访问URL
}
type GetAuthorizationDocumentByOrderReq struct {
OrderId string `json:"orderId" validate:"required"` // 订单ID
}
type GetAuthorizationDocumentByOrderResp struct {
Documents []AuthorizationDocumentInfo `json:"documents"` // 授权书列表
}
type GetAuthorizationDocumentReq struct {
DocumentId string `json:"documentId" validate:"required"` // 授权书ID
}
type GetAuthorizationDocumentResp struct {
DocumentId string `json:"documentId"` // 授权书ID
UserId string `json:"userId"` // 用户ID
OrderId string `json:"orderId"` // 订单ID
QueryId string `json:"queryId"` // 查询ID
FileName string `json:"fileName"` // 文件名
FileUrl string `json:"fileUrl"` // 文件访问URL
FileSize int64 `json:"fileSize"` // 文件大小
FileType string `json:"fileType"` // 文件类型
Status string `json:"status"` // 状态
CreateTime string `json:"createTime"` // 创建时间
}

View File

@@ -1,7 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type GetNotificationsResp struct {
Notifications []Notification `json:"notifications"` // 通知列表
Total int64 `json:"total"` // 总记录数
}

View File

@@ -1,28 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type IapCallbackReq struct {
OrderID string `json:"order_id" validate:"required"`
TransactionReceipt string `json:"transaction_receipt" validate:"required"`
}
type PaymentCheckReq struct {
OrderNo string `json:"order_no" validate:"required"`
}
type PaymentCheckResp struct {
Type string `json:"type"`
Status string `json:"status"`
}
type PaymentReq struct {
Id string `json:"id"`
PayMethod string `json:"pay_method"` // 支付方式: wechat, alipay, appleiap, test(仅开发环境), test_empty(仅开发环境-空报告模式)
PayType string `json:"pay_type" validate:"required,oneof=query agent_vip agent_upgrade"`
}
type PaymentResp struct {
PrepayData interface{} `json:"prepay_data"`
PrepayId string `json:"prepay_id"`
OrderNo string `json:"order_no"`
}

View File

@@ -1,14 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type GetProductByEnRequest struct {
ProductEn string `path:"product_en"`
}
type GetProductByIDRequest struct {
Id string `path:"id"`
}
type ProductResponse struct {
Product
}

View File

@@ -1,90 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type QueryDetailByOrderIdReq struct {
OrderId string `path:"order_id"`
}
type QueryDetailByOrderNoReq struct {
OrderNo string `path:"order_no"`
}
type QueryExampleReq struct {
Feature string `form:"feature"`
}
type QueryGenerateShareLinkReq struct {
OrderId *string `json:"order_id,optional"`
OrderNo *string `json:"order_no,optional"`
}
type QueryGenerateShareLinkResp struct {
ShareLink string `json:"share_link"`
}
type QueryListReq struct {
Page int64 `form:"page"` // 页码
PageSize int64 `form:"page_size"` // 每页数据量
}
type QueryListResp struct {
Total int64 `json:"total"` // 总记录数
List []Query `json:"list"` // 查询列表
}
type QueryProvisionalOrderReq struct {
Id string `path:"id"`
}
type QueryProvisionalOrderResp struct {
Name string `json:"name"`
IdCard string `json:"id_card"`
Mobile string `json:"mobile"`
Product Product `json:"product"`
}
type QueryRetryReq struct {
Id string `path:"id"`
}
type QueryRetryResp struct {
Query
}
type QueryServiceReq struct {
Product string `path:"product"`
Data string `json:"data" validate:"required"`
AgentIdentifier string `json:"agent_identifier,optional"`
App bool `json:"app,optional"`
}
type QueryServiceResp struct {
Id string `json:"id"`
AccessToken string `json:"accessToken"`
AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"`
}
type QueryShareDetailReq struct {
Id string `path:"id"`
}
type QuerySingleTestReq struct {
Params map[string]interface{} `json:"params"`
Api string `json:"api"`
}
type QuerySingleTestResp struct {
Data interface{} `json:"data"`
Api string `json:"api"`
}
type UpdateQueryDataReq struct {
Id string `json:"id"` // 查询ID
QueryData string `json:"query_data"` // 查询数据(未加密的JSON)
}
type UpdateQueryDataResp struct {
Id string `json:"id"`
UpdatedAt string `json:"updated_at"` // 更新时间
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,73 +0,0 @@
// Code generated by goctl. DO NOT EDIT.
package types
type AuthReq struct {
Platform string `json:"platform"` // browser|wxh5|wxmini
Code string `json:"code,optional"`
}
type AuthResp struct {
AccessToken string `json:"accessToken"`
AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"`
UserType int64 `json:"userType"`
HasMobile bool `json:"hasMobile"`
IsAgent bool `json:"isAgent"`
}
type BindMobileReq struct {
Mobile string `json:"mobile" validate:"required,mobile"`
Code string `json:"code" validate:"required"`
}
type BindMobileResp struct {
AccessToken string `json:"accessToken"`
AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"`
}
type GetSignatureReq struct {
Url string `json:"url"`
}
type GetSignatureResp struct {
AppId string `json:"appId"`
Timestamp int64 `json:"timestamp"`
NonceStr string `json:"nonceStr"`
Signature string `json:"signature"`
}
type MobileCodeLoginReq struct {
Mobile string `json:"mobile"`
Code string `json:"code" validate:"required"`
}
type MobileCodeLoginResp struct {
AccessToken string `json:"accessToken"`
AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"`
}
type UserInfoResp struct {
UserInfo User `json:"userInfo"`
}
type WXH5AuthReq struct {
Code string `json:"code"`
}
type WXH5AuthResp struct {
AccessToken string `json:"accessToken"`
AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"`
}
type WXMiniAuthReq struct {
Code string `json:"code"`
}
type WXMiniAuthResp struct {
AccessToken string `json:"accessToken"`
AccessExpire int64 `json:"accessExpire"`
RefreshAfter int64 `json:"refreshAfter"`
}