f
This commit is contained in:
@@ -45,8 +45,10 @@ service main {
|
|||||||
type (
|
type (
|
||||||
// 创建功能请求
|
// 创建功能请求
|
||||||
AdminCreateFeatureReq {
|
AdminCreateFeatureReq {
|
||||||
ApiId string `json:"api_id"` // API标识
|
ApiId string `json:"api_id"` // API标识
|
||||||
Name string `json:"name"` // 描述
|
Name string `json:"name"` // 描述
|
||||||
|
WhitelistPrice *float64 `json:"whitelist_price,optional"` // 白名单屏蔽价格(单位:元)
|
||||||
|
CostPrice *float64 `json:"cost_price,optional"` // 天远API调用成本价(单位:元)
|
||||||
}
|
}
|
||||||
// 创建功能响应
|
// 创建功能响应
|
||||||
AdminCreateFeatureResp {
|
AdminCreateFeatureResp {
|
||||||
@@ -54,9 +56,11 @@ type (
|
|||||||
}
|
}
|
||||||
// 更新功能请求
|
// 更新功能请求
|
||||||
AdminUpdateFeatureReq {
|
AdminUpdateFeatureReq {
|
||||||
Id string `path:"id"` // 功能ID
|
Id string `path:"id"` // 功能ID
|
||||||
ApiId *string `json:"api_id,optional"` // API标识
|
ApiId *string `json:"api_id,optional"` // API标识
|
||||||
Name *string `json:"name,optional"` // 描述
|
Name *string `json:"name,optional"` // 描述
|
||||||
|
WhitelistPrice *float64 `json:"whitelist_price,optional"` // 白名单屏蔽价格(单位:元)
|
||||||
|
CostPrice *float64 `json:"cost_price,optional"` // 天远API调用成本价(单位:元)
|
||||||
}
|
}
|
||||||
// 更新功能响应
|
// 更新功能响应
|
||||||
AdminUpdateFeatureResp {
|
AdminUpdateFeatureResp {
|
||||||
@@ -79,11 +83,13 @@ type (
|
|||||||
}
|
}
|
||||||
// 功能列表项
|
// 功能列表项
|
||||||
FeatureListItem {
|
FeatureListItem {
|
||||||
Id string `json:"id"` // 功能ID
|
Id string `json:"id"` // 功能ID
|
||||||
ApiId string `json:"api_id"` // API标识
|
ApiId string `json:"api_id"` // API标识
|
||||||
Name string `json:"name"` // 描述
|
Name string `json:"name"` // 描述
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
WhitelistPrice float64 `json:"whitelist_price"` // 白名单屏蔽价格(单位:元)
|
||||||
UpdateTime string `json:"update_time"` // 更新时间
|
CostPrice float64 `json:"cost_price"` // 天远API调用成本价(单位:元)
|
||||||
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
|
UpdateTime string `json:"update_time"` // 更新时间
|
||||||
}
|
}
|
||||||
// 获取功能列表响应
|
// 获取功能列表响应
|
||||||
AdminGetFeatureListResp {
|
AdminGetFeatureListResp {
|
||||||
@@ -96,11 +102,13 @@ type (
|
|||||||
}
|
}
|
||||||
// 获取功能详情响应
|
// 获取功能详情响应
|
||||||
AdminGetFeatureDetailResp {
|
AdminGetFeatureDetailResp {
|
||||||
Id string `json:"id"` // 功能ID
|
Id string `json:"id"` // 功能ID
|
||||||
ApiId string `json:"api_id"` // API标识
|
ApiId string `json:"api_id"` // API标识
|
||||||
Name string `json:"name"` // 描述
|
Name string `json:"name"` // 描述
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
WhitelistPrice float64 `json:"whitelist_price"` // 白名单屏蔽价格(单位:元)
|
||||||
UpdateTime string `json:"update_time"` // 更新时间
|
CostPrice float64 `json:"cost_price"` // 天远API调用成本价(单位:元)
|
||||||
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
|
UpdateTime string `json:"update_time"` // 更新时间
|
||||||
}
|
}
|
||||||
// 配置功能示例数据请求
|
// 配置功能示例数据请求
|
||||||
AdminConfigFeatureExampleReq {
|
AdminConfigFeatureExampleReq {
|
||||||
|
|||||||
93
app/main/api/desc/admin/dashboard.api
Normal file
93
app/main/api/desc/admin/dashboard.api
Normal 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"` // 数值
|
||||||
|
}
|
||||||
|
)
|
||||||
@@ -251,6 +251,32 @@ service main {
|
|||||||
// 获取推广查询报告列表
|
// 获取推广查询报告列表
|
||||||
@handler GetPromotionQueryList
|
@handler GetPromotionQueryList
|
||||||
get /promotion/query/list (GetPromotionQueryListReq) returns (GetPromotionQueryListResp)
|
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 (
|
type (
|
||||||
@@ -581,11 +607,82 @@ type (
|
|||||||
List []PromotionQueryItem `json:"list"` // 列表
|
List []PromotionQueryItem `json:"list"` // 列表
|
||||||
}
|
}
|
||||||
PromotionQueryItem {
|
PromotionQueryItem {
|
||||||
Id string `json:"id"` // 查询ID
|
Id string `json:"id"` // 查询ID
|
||||||
OrderId string `json:"order_id"` // 订单ID
|
OrderId string `json:"order_id"` // 订单ID
|
||||||
ProductName string `json:"product_name"` // 产品名称
|
ProductName string `json:"product_name"` // 产品名称
|
||||||
CreateTime string `json:"create_time"` // 创建时间
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
QueryState string `json:"query_state"` // 查询状态
|
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"` // 查询记录ID(Query表的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"` // 是否是当前代理推广的订单
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import "./admin/platform_user.api"
|
|||||||
import "./admin/notification.api"
|
import "./admin/notification.api"
|
||||||
import "./admin/admin_product.api"
|
import "./admin/admin_product.api"
|
||||||
import "./admin/admin_feature.api"
|
import "./admin/admin_feature.api"
|
||||||
|
import "./admin/dashboard.api"
|
||||||
import "./admin/admin_query.api"
|
import "./admin/admin_query.api"
|
||||||
import "./admin/admin_agent.api"
|
import "./admin/admin_agent.api"
|
||||||
import "./admin/admin_api.api"
|
import "./admin/admin_api.api"
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
29
app/main/api/internal/handler/agent/offlinefeaturehandler.go
Normal file
29
app/main/api/internal/handler/agent/offlinefeaturehandler.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
admin_agent "qnc-server/app/main/api/internal/handler/admin_agent"
|
admin_agent "qnc-server/app/main/api/internal/handler/admin_agent"
|
||||||
admin_api "qnc-server/app/main/api/internal/handler/admin_api"
|
admin_api "qnc-server/app/main/api/internal/handler/admin_api"
|
||||||
admin_auth "qnc-server/app/main/api/internal/handler/admin_auth"
|
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_feature "qnc-server/app/main/api/internal/handler/admin_feature"
|
||||||
admin_menu "qnc-server/app/main/api/internal/handler/admin_menu"
|
admin_menu "qnc-server/app/main/api/internal/handler/admin_menu"
|
||||||
admin_notification "qnc-server/app/main/api/internal/handler/admin_notification"
|
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"),
|
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(
|
server.AddRoutes(
|
||||||
rest.WithMiddlewares(
|
rest.WithMiddlewares(
|
||||||
[]rest.Middleware{serverCtx.AdminAuthInterceptor},
|
[]rest.Middleware{serverCtx.AdminAuthInterceptor},
|
||||||
@@ -671,6 +686,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/level/privilege",
|
Path: "/level/privilege",
|
||||||
Handler: agent.GetLevelPrivilegeHandler(serverCtx),
|
Handler: agent.GetLevelPrivilegeHandler(serverCtx),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Method: http.MethodGet,
|
||||||
|
Path: "/order/agent",
|
||||||
|
Handler: agent.CheckOrderAgentHandler(serverCtx),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Method: http.MethodGet,
|
Method: http.MethodGet,
|
||||||
Path: "/product_config",
|
Path: "/product_config",
|
||||||
@@ -736,6 +756,31 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
|||||||
Path: "/upgrade/subordinate",
|
Path: "/upgrade/subordinate",
|
||||||
Handler: agent.UpgradeSubordinateHandler(serverCtx),
|
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,
|
Method: http.MethodPost,
|
||||||
Path: "/withdrawal/apply",
|
Path: "/withdrawal/apply",
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -34,6 +34,12 @@ func (l *AdminCreateFeatureLogic) AdminCreateFeature(req *types.AdminCreateFeatu
|
|||||||
ApiId: req.ApiId,
|
ApiId: req.ApiId,
|
||||||
Name: req.Name,
|
Name: req.Name,
|
||||||
}
|
}
|
||||||
|
if req.WhitelistPrice != nil {
|
||||||
|
data.WhitelistPrice = *req.WhitelistPrice
|
||||||
|
}
|
||||||
|
if req.CostPrice != nil {
|
||||||
|
data.CostPrice = *req.CostPrice
|
||||||
|
}
|
||||||
|
|
||||||
// 2. 数据库操作
|
// 2. 数据库操作
|
||||||
result, err := l.svcCtx.FeatureModel.Insert(l.ctx, nil, data)
|
result, err := l.svcCtx.FeatureModel.Insert(l.ctx, nil, data)
|
||||||
|
|||||||
@@ -35,11 +35,13 @@ func (l *AdminGetFeatureDetailLogic) AdminGetFeatureDetail(req *types.AdminGetFe
|
|||||||
|
|
||||||
// 2. 构建响应
|
// 2. 构建响应
|
||||||
resp = &types.AdminGetFeatureDetailResp{
|
resp = &types.AdminGetFeatureDetailResp{
|
||||||
Id: record.Id,
|
Id: record.Id,
|
||||||
ApiId: record.ApiId,
|
ApiId: record.ApiId,
|
||||||
Name: record.Name,
|
Name: record.Name,
|
||||||
CreateTime: record.CreateTime.Format("2006-01-02 15:04:05"),
|
WhitelistPrice: record.WhitelistPrice,
|
||||||
UpdateTime: record.UpdateTime.Format("2006-01-02 15:04:05"),
|
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
|
return resp, nil
|
||||||
|
|||||||
@@ -49,11 +49,13 @@ func (l *AdminGetFeatureListLogic) AdminGetFeatureList(req *types.AdminGetFeatur
|
|||||||
items := make([]types.FeatureListItem, 0, len(list))
|
items := make([]types.FeatureListItem, 0, len(list))
|
||||||
for _, item := range list {
|
for _, item := range list {
|
||||||
listItem := types.FeatureListItem{
|
listItem := types.FeatureListItem{
|
||||||
Id: item.Id,
|
Id: item.Id,
|
||||||
ApiId: item.ApiId,
|
ApiId: item.ApiId,
|
||||||
Name: item.Name,
|
Name: item.Name,
|
||||||
CreateTime: item.CreateTime.Format("2006-01-02 15:04:05"),
|
WhitelistPrice: item.WhitelistPrice,
|
||||||
UpdateTime: item.UpdateTime.Format("2006-01-02 15:04:05"),
|
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)
|
items = append(items, listItem)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ func (l *AdminUpdateFeatureLogic) AdminUpdateFeature(req *types.AdminUpdateFeatu
|
|||||||
if req.Name != nil && *req.Name != "" {
|
if req.Name != nil && *req.Name != "" {
|
||||||
record.Name = *req.Name
|
record.Name = *req.Name
|
||||||
}
|
}
|
||||||
|
if req.WhitelistPrice != nil {
|
||||||
|
record.WhitelistPrice = *req.WhitelistPrice
|
||||||
|
}
|
||||||
|
if req.CostPrice != nil {
|
||||||
|
record.CostPrice = *req.CostPrice
|
||||||
|
}
|
||||||
|
|
||||||
// 4. 执行更新操作
|
// 4. 执行更新操作
|
||||||
err = l.svcCtx.FeatureModel.UpdateWithVersion(l.ctx, nil, record)
|
err = l.svcCtx.FeatureModel.UpdateWithVersion(l.ctx, nil, record)
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
53
app/main/api/internal/logic/agent/checkorderagentlogic.go
Normal file
53
app/main/api/internal/logic/agent/checkorderagentlogic.go
Normal 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
|
||||||
|
}
|
||||||
127
app/main/api/internal/logic/agent/createwhitelistorderlogic.go
Normal file
127
app/main/api/internal/logic/agent/createwhitelistorderlogic.go
Normal 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
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
}
|
||||||
77
app/main/api/internal/logic/agent/getwhitelistlistlogic.go
Normal file
77
app/main/api/internal/logic/agent/getwhitelistlistlogic.go
Normal 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
|
||||||
|
}
|
||||||
70
app/main/api/internal/logic/agent/offlinefeaturelogic.go
Normal file
70
app/main/api/internal/logic/agent/offlinefeaturelogic.go
Normal 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), ¶ms); 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
|
||||||
|
}
|
||||||
@@ -115,6 +115,8 @@ func BuildEncryptedQuery(ctx context.Context, svcCtx *svc.ServiceContext, queryM
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 报告结构体复制失败, %v", err)
|
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 报告结构体复制失败, %v", err)
|
||||||
}
|
}
|
||||||
|
// 显式写入查询记录 ID,供前端报告页「模块下架」等白名单能力使用
|
||||||
|
query.Id = queryModel.Id
|
||||||
product, err := svcCtx.ProductModel.FindOne(ctx, queryModel.ProductId)
|
product, err := svcCtx.ProductModel.FindOne(ctx, queryModel.ProductId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 获取商品信息失败, %v", err)
|
return "", errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "报告查询, 获取商品信息失败, %v", err)
|
||||||
|
|||||||
@@ -33,19 +33,33 @@ func generateAuthDateRange() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ApiRequestService struct {
|
type ApiRequestService struct {
|
||||||
config config.Config
|
config config.Config
|
||||||
featureModel model.FeatureModel
|
featureModel model.FeatureModel
|
||||||
productFeatureModel model.ProductFeatureModel
|
productFeatureModel model.ProductFeatureModel
|
||||||
tianyuanapi *tianyuanapi.Client
|
userFeatureWhitelistModel model.UserFeatureWhitelistModel
|
||||||
|
whitelistService *WhitelistService
|
||||||
|
tianyuanapi *tianyuanapi.Client
|
||||||
|
tianyuanapiCallLogService *TianyuanapiCallLogService
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewApiRequestService 是一个构造函数,用于初始化 ApiRequestService
|
// NewApiRequestService 构造函数
|
||||||
func NewApiRequestService(c config.Config, featureModel model.FeatureModel, productFeatureModel model.ProductFeatureModel, tianyuanapi *tianyuanapi.Client) *ApiRequestService {
|
func NewApiRequestService(
|
||||||
|
c config.Config,
|
||||||
|
featureModel model.FeatureModel,
|
||||||
|
productFeatureModel model.ProductFeatureModel,
|
||||||
|
userFeatureWhitelistModel model.UserFeatureWhitelistModel,
|
||||||
|
tianyuanapi *tianyuanapi.Client,
|
||||||
|
tianyuanapiCallLogService *TianyuanapiCallLogService,
|
||||||
|
whitelistService *WhitelistService,
|
||||||
|
) *ApiRequestService {
|
||||||
return &ApiRequestService{
|
return &ApiRequestService{
|
||||||
config: c,
|
config: c,
|
||||||
featureModel: featureModel,
|
featureModel: featureModel,
|
||||||
productFeatureModel: productFeatureModel,
|
productFeatureModel: productFeatureModel,
|
||||||
tianyuanapi: tianyuanapi,
|
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) {
|
func (a *ApiRequestService) ProcessRequests(params []byte, productID string) ([]byte, error) {
|
||||||
var ctx, cancel = context.WithCancel(context.Background())
|
var ctx, cancel = context.WithCancel(context.Background())
|
||||||
defer cancel()
|
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, "")
|
productFeatureList, findProductFeatureErr := a.productFeatureModel.FindAll(ctx, build, "")
|
||||||
if findProductFeatureErr != nil {
|
if findProductFeatureErr != nil {
|
||||||
return nil, findProductFeatureErr
|
return nil, findProductFeatureErr
|
||||||
}
|
}
|
||||||
var featureIDs []string
|
var featureIDs []string
|
||||||
isImportantMap := make(map[string]int64, len(productFeatureList))
|
isImportantMap := make(map[string]int64, len(productFeatureList))
|
||||||
for _, pf := range productFeatureList {
|
for _, pf := range productFeatureList {
|
||||||
featureIDs = append(featureIDs, pf.FeatureId)
|
featureIDs = append(featureIDs, pf.FeatureId)
|
||||||
isImportantMap[pf.FeatureId] = pf.IsImportant
|
isImportantMap[pf.FeatureId] = pf.IsImportant
|
||||||
}
|
}
|
||||||
if len(featureIDs) == 0 {
|
if len(featureIDs) == 0 {
|
||||||
return nil, errors.New("featureIDs 是空的")
|
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, "")
|
featureList, findFeatureErr := a.featureModel.FindAll(ctx, builder, "")
|
||||||
if findFeatureErr != nil {
|
if findFeatureErr != nil {
|
||||||
return nil, findFeatureErr
|
return nil, findFeatureErr
|
||||||
@@ -109,12 +133,19 @@ func (a *ApiRequestService) ProcessRequests(params []byte, productID string) ([]
|
|||||||
Success: false,
|
Success: false,
|
||||||
}
|
}
|
||||||
timestamp := time.Now().Format("2006-01-02 15:04:05")
|
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 (
|
var (
|
||||||
resp json.RawMessage
|
resp json.RawMessage
|
||||||
preprocessErr error
|
preprocessErr error
|
||||||
)
|
)
|
||||||
// 若 isImportantMap[feature.ID] == 1,则表示需要在出错时重试
|
isImportant := isImportantMap[feature.Id] == 1
|
||||||
isImportant := isImportantMap[feature.Id] == 1
|
|
||||||
tryCount := 0
|
tryCount := 0
|
||||||
for {
|
for {
|
||||||
tryCount++
|
tryCount++
|
||||||
|
|||||||
190
app/main/api/internal/service/tianyuanapiCallLogService.go
Normal file
190
app/main/api/internal/service/tianyuanapiCallLogService.go
Normal 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
|
||||||
|
}
|
||||||
450
app/main/api/internal/service/whitelistService.go
Normal file
450
app/main/api/internal/service/whitelistService.go
Normal 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
|
||||||
|
}
|
||||||
@@ -34,6 +34,11 @@ type ServiceContext struct {
|
|||||||
FeatureModel model.FeatureModel
|
FeatureModel model.FeatureModel
|
||||||
ProductFeatureModel model.ProductFeatureModel
|
ProductFeatureModel model.ProductFeatureModel
|
||||||
|
|
||||||
|
// 白名单相关模型
|
||||||
|
UserFeatureWhitelistModel model.UserFeatureWhitelistModel
|
||||||
|
WhitelistOrderModel model.WhitelistOrderModel
|
||||||
|
WhitelistOrderItemModel model.WhitelistOrderItemModel
|
||||||
|
|
||||||
// 订单相关模型
|
// 订单相关模型
|
||||||
OrderModel model.OrderModel
|
OrderModel model.OrderModel
|
||||||
OrderRefundModel model.OrderRefundModel
|
OrderRefundModel model.OrderRefundModel
|
||||||
@@ -77,11 +82,15 @@ type ServiceContext struct {
|
|||||||
GlobalNotificationsModel model.GlobalNotificationsModel
|
GlobalNotificationsModel model.GlobalNotificationsModel
|
||||||
AuthorizationDocumentModel model.AuthorizationDocumentModel
|
AuthorizationDocumentModel model.AuthorizationDocumentModel
|
||||||
|
|
||||||
|
// 第三方服务
|
||||||
|
TianyuanapiCallLogService *service.TianyuanapiCallLogService
|
||||||
|
|
||||||
// 服务
|
// 服务
|
||||||
AlipayService *service.AliPayService
|
AlipayService *service.AliPayService
|
||||||
WechatPayService *service.WechatPayService
|
WechatPayService *service.WechatPayService
|
||||||
ApplePayService *service.ApplePayService
|
ApplePayService *service.ApplePayService
|
||||||
ApiRequestService *service.ApiRequestService
|
ApiRequestService *service.ApiRequestService
|
||||||
|
WhitelistService *service.WhitelistService
|
||||||
AsynqServer *asynq.Server
|
AsynqServer *asynq.Server
|
||||||
AsynqService *service.AsynqService
|
AsynqService *service.AsynqService
|
||||||
VerificationService *service.VerificationService
|
VerificationService *service.VerificationService
|
||||||
@@ -152,10 +161,16 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||||||
adminDictDataModel := model.NewAdminDictDataModel(db, cacheConf)
|
adminDictDataModel := model.NewAdminDictDataModel(db, cacheConf)
|
||||||
adminDictTypeModel := model.NewAdminDictTypeModel(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)
|
exampleModel := model.NewExampleModel(db, cacheConf)
|
||||||
globalNotificationsModel := model.NewGlobalNotificationsModel(db, cacheConf)
|
globalNotificationsModel := model.NewGlobalNotificationsModel(db, cacheConf)
|
||||||
authorizationDocumentModel := model.NewAuthorizationDocumentModel(db, cacheConf)
|
authorizationDocumentModel := model.NewAuthorizationDocumentModel(db, cacheConf)
|
||||||
|
tianyuanapiCallLogModel := model.NewTianyuanapiCallLogModel(db, cacheConf)
|
||||||
|
|
||||||
// ============================== 第三方服务初始化 ==============================
|
// ============================== 第三方服务初始化 ==============================
|
||||||
tianyuanapi, err := tianyuanapi.NewClient(tianyuanapi.Config{
|
tianyuanapi, err := tianyuanapi.NewClient(tianyuanapi.Config{
|
||||||
@@ -172,7 +187,9 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||||||
alipayService := service.NewAliPayService(c)
|
alipayService := service.NewAliPayService(c)
|
||||||
wechatPayService := service.NewWechatPayService(c, userAuthModel, service.InitTypeWxPayPubKey)
|
wechatPayService := service.NewWechatPayService(c, userAuthModel, service.InitTypeWxPayPubKey)
|
||||||
applePayService := service.NewApplePayService(c)
|
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)
|
verificationService := service.NewVerificationService(c, tianyuanapi, apiRequestService)
|
||||||
asynqService := service.NewAsynqService(c)
|
asynqService := service.NewAsynqService(c)
|
||||||
agentService := service.NewAgentService(c, orderModel, agentModel, agentWalletModel,
|
agentService := service.NewAgentService(c, orderModel, agentModel, agentWalletModel,
|
||||||
@@ -214,6 +231,11 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||||||
FeatureModel: featureModel,
|
FeatureModel: featureModel,
|
||||||
ProductFeatureModel: productFeatureModel,
|
ProductFeatureModel: productFeatureModel,
|
||||||
|
|
||||||
|
// 白名单相关模型
|
||||||
|
UserFeatureWhitelistModel: userFeatureWhitelistModel,
|
||||||
|
WhitelistOrderModel: whitelistOrderModel,
|
||||||
|
WhitelistOrderItemModel: whitelistOrderItemModel,
|
||||||
|
|
||||||
// 订单相关模型
|
// 订单相关模型
|
||||||
OrderModel: orderModel,
|
OrderModel: orderModel,
|
||||||
QueryModel: queryModel,
|
QueryModel: queryModel,
|
||||||
@@ -257,11 +279,15 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||||||
GlobalNotificationsModel: globalNotificationsModel,
|
GlobalNotificationsModel: globalNotificationsModel,
|
||||||
AuthorizationDocumentModel: authorizationDocumentModel,
|
AuthorizationDocumentModel: authorizationDocumentModel,
|
||||||
|
|
||||||
|
// 第三方服务
|
||||||
|
TianyuanapiCallLogService: tianyuanapiCallLogService,
|
||||||
|
|
||||||
// 服务
|
// 服务
|
||||||
AlipayService: alipayService,
|
AlipayService: alipayService,
|
||||||
WechatPayService: wechatPayService,
|
WechatPayService: wechatPayService,
|
||||||
ApplePayService: applePayService,
|
ApplePayService: applePayService,
|
||||||
ApiRequestService: apiRequestService,
|
ApiRequestService: apiRequestService,
|
||||||
|
WhitelistService: whitelistService,
|
||||||
AsynqServer: asynqServer,
|
AsynqServer: asynqServer,
|
||||||
AsynqService: asynqService,
|
AsynqService: asynqService,
|
||||||
VerificationService: verificationService,
|
VerificationService: verificationService,
|
||||||
|
|||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -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"` // 是否成功
|
|
||||||
}
|
|
||||||
@@ -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"` // 是否成功
|
|
||||||
}
|
|
||||||
@@ -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"` // 是否成功
|
|
||||||
}
|
|
||||||
@@ -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"` // 是否成功
|
|
||||||
}
|
|
||||||
@@ -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"` // 是否成功
|
|
||||||
}
|
|
||||||
@@ -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"` // 是否成功
|
|
||||||
}
|
|
||||||
@@ -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"` // 是否成功
|
|
||||||
}
|
|
||||||
@@ -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"` // 是否成功
|
|
||||||
}
|
|
||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -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"` // 角色编码列表
|
|
||||||
}
|
|
||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -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"` // 创建时间
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
// Code generated by goctl. DO NOT EDIT.
|
|
||||||
package types
|
|
||||||
|
|
||||||
type GetNotificationsResp struct {
|
|
||||||
Notifications []Notification `json:"notifications"` // 通知列表
|
|
||||||
Total int64 `json:"total"` // 总记录数
|
|
||||||
}
|
|
||||||
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
}
|
|
||||||
@@ -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
@@ -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"`
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,6 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"qnc-server/common/globalkey"
|
|
||||||
|
|
||||||
"github.com/Masterminds/squirrel"
|
"github.com/Masterminds/squirrel"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -21,6 +19,7 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
"github.com/zeromicro/go-zero/core/stringx"
|
"github.com/zeromicro/go-zero/core/stringx"
|
||||||
|
"qnc-server/common/globalkey"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -59,14 +58,16 @@ type (
|
|||||||
}
|
}
|
||||||
|
|
||||||
Feature struct {
|
Feature struct {
|
||||||
Id string `db:"id"`
|
Id string `db:"id"`
|
||||||
CreateTime time.Time `db:"create_time"` // 创建时间
|
CreateTime time.Time `db:"create_time"` // 创建时间
|
||||||
UpdateTime time.Time `db:"update_time"` // 更新时间
|
UpdateTime time.Time `db:"update_time"` // 更新时间
|
||||||
DeleteTime sql.NullTime `db:"delete_time"` // 删除时间
|
DeleteTime sql.NullTime `db:"delete_time"` // 删除时间
|
||||||
DelState int64 `db:"del_state"` // 删除状态
|
DelState int64 `db:"del_state"` // 删除状态
|
||||||
Version int64 `db:"version"` // 版本号
|
Version int64 `db:"version"` // 版本号
|
||||||
ApiId string `db:"api_id"` // API标识
|
ApiId string `db:"api_id"` // API标识
|
||||||
Name string `db:"name"` // 描述
|
Name string `db:"name"` // 描述
|
||||||
|
WhitelistPrice float64 `db:"whitelist_price"` // 白名单屏蔽价格(元)
|
||||||
|
CostPrice float64 `db:"cost_price"` // 天远API调用成本价(元)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -83,11 +84,11 @@ func (m *defaultFeatureModel) Insert(ctx context.Context, session sqlx.Session,
|
|||||||
qncFeatureApiIdKey := fmt.Sprintf("%s%v", cacheQncFeatureApiIdPrefix, data.ApiId)
|
qncFeatureApiIdKey := fmt.Sprintf("%s%v", cacheQncFeatureApiIdPrefix, data.ApiId)
|
||||||
qncFeatureIdKey := fmt.Sprintf("%s%v", cacheQncFeatureIdPrefix, data.Id)
|
qncFeatureIdKey := fmt.Sprintf("%s%v", cacheQncFeatureIdPrefix, data.Id)
|
||||||
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?)", m.table, featureRowsExpectAutoSet)
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?)", m.table, featureRowsExpectAutoSet)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
return session.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.ApiId, data.Name)
|
return session.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.ApiId, data.Name, data.WhitelistPrice, data.CostPrice)
|
||||||
}
|
}
|
||||||
return conn.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.ApiId, data.Name)
|
return conn.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.ApiId, data.Name, data.WhitelistPrice, data.CostPrice)
|
||||||
}, qncFeatureApiIdKey, qncFeatureIdKey)
|
}, qncFeatureApiIdKey, qncFeatureIdKey)
|
||||||
}
|
}
|
||||||
func (m *defaultFeatureModel) insertUUID(data *Feature) {
|
func (m *defaultFeatureModel) insertUUID(data *Feature) {
|
||||||
@@ -154,9 +155,9 @@ func (m *defaultFeatureModel) Update(ctx context.Context, session sqlx.Session,
|
|||||||
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, featureRowsWithPlaceHolder)
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, featureRowsWithPlaceHolder)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.Id)
|
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.WhitelistPrice, newData.CostPrice, newData.Id)
|
||||||
}
|
}
|
||||||
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.Id)
|
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.WhitelistPrice, newData.CostPrice, newData.Id)
|
||||||
}, qncFeatureApiIdKey, qncFeatureIdKey)
|
}, qncFeatureApiIdKey, qncFeatureIdKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,9 +178,9 @@ func (m *defaultFeatureModel) UpdateWithVersion(ctx context.Context, session sql
|
|||||||
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, featureRowsWithPlaceHolder)
|
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, featureRowsWithPlaceHolder)
|
||||||
if session != nil {
|
if session != nil {
|
||||||
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.Id, oldVersion)
|
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.WhitelistPrice, newData.CostPrice, newData.Id, oldVersion)
|
||||||
}
|
}
|
||||||
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.Id, oldVersion)
|
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.ApiId, newData.Name, newData.WhitelistPrice, newData.CostPrice, newData.Id, oldVersion)
|
||||||
}, qncFeatureApiIdKey, qncFeatureIdKey)
|
}, qncFeatureApiIdKey, qncFeatureIdKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
27
app/main/model/tianyuanapiCallLogModel.go
Normal file
27
app/main/model/tianyuanapiCallLogModel.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ TianyuanapiCallLogModel = (*customTianyuanapiCallLogModel)(nil)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// TianyuanapiCallLogModel is an interface to be customized, add more methods here,
|
||||||
|
// and implement the added methods in customTianyuanapiCallLogModel.
|
||||||
|
TianyuanapiCallLogModel interface {
|
||||||
|
tianyuanapiCallLogModel
|
||||||
|
}
|
||||||
|
|
||||||
|
customTianyuanapiCallLogModel struct {
|
||||||
|
*defaultTianyuanapiCallLogModel
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewTianyuanapiCallLogModel returns a model for the database table.
|
||||||
|
func NewTianyuanapiCallLogModel(conn sqlx.SqlConn, c cache.CacheConf) TianyuanapiCallLogModel {
|
||||||
|
return &customTianyuanapiCallLogModel{
|
||||||
|
defaultTianyuanapiCallLogModel: newTianyuanapiCallLogModel(conn, c),
|
||||||
|
}
|
||||||
|
}
|
||||||
398
app/main/model/tianyuanapiCallLogModel_gen.go
Normal file
398
app/main/model/tianyuanapiCallLogModel_gen.go
Normal file
@@ -0,0 +1,398 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT!
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"github.com/zeromicro/go-zero/core/stringx"
|
||||||
|
"qnc-server/common/globalkey"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
tianyuanapiCallLogFieldNames = builder.RawFieldNames(&TianyuanapiCallLog{})
|
||||||
|
tianyuanapiCallLogRows = strings.Join(tianyuanapiCallLogFieldNames, ",")
|
||||||
|
tianyuanapiCallLogRowsExpectAutoSet = strings.Join(stringx.Remove(tianyuanapiCallLogFieldNames, "`id`", "`create_time`", "`update_time`"), ",")
|
||||||
|
tianyuanapiCallLogRowsWithPlaceHolder = strings.Join(stringx.Remove(tianyuanapiCallLogFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||||||
|
|
||||||
|
cacheQncTianyuanapiCallLogIdPrefix = "cache:qnc:tianyuanapiCallLog:id:"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
tianyuanapiCallLogModel interface {
|
||||||
|
Insert(ctx context.Context, session sqlx.Session, data *TianyuanapiCallLog) (sql.Result, error)
|
||||||
|
FindOne(ctx context.Context, id int64) (*TianyuanapiCallLog, error)
|
||||||
|
Update(ctx context.Context, session sqlx.Session, data *TianyuanapiCallLog) (sql.Result, error)
|
||||||
|
UpdateWithVersion(ctx context.Context, session sqlx.Session, data *TianyuanapiCallLog) error
|
||||||
|
Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error
|
||||||
|
SelectBuilder() squirrel.SelectBuilder
|
||||||
|
DeleteSoft(ctx context.Context, session sqlx.Session, data *TianyuanapiCallLog) error
|
||||||
|
FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error)
|
||||||
|
FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error)
|
||||||
|
FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*TianyuanapiCallLog, error)
|
||||||
|
FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*TianyuanapiCallLog, error)
|
||||||
|
FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*TianyuanapiCallLog, int64, error)
|
||||||
|
FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*TianyuanapiCallLog, error)
|
||||||
|
FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*TianyuanapiCallLog, error)
|
||||||
|
Delete(ctx context.Context, session sqlx.Session, id int64) error
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultTianyuanapiCallLogModel struct {
|
||||||
|
sqlc.CachedConn
|
||||||
|
table string
|
||||||
|
}
|
||||||
|
|
||||||
|
TianyuanapiCallLog struct {
|
||||||
|
Id int64 `db:"id"`
|
||||||
|
FeatureId string `db:"feature_id"` // 功能ID(关联feature表)
|
||||||
|
ApiId string `db:"api_id"` // API标识
|
||||||
|
OrderId sql.NullString `db:"order_id"` // 订单ID
|
||||||
|
QueryId sql.NullString `db:"query_id"` // 查询ID
|
||||||
|
CallStatus int64 `db:"call_status"` // 调用状态:0=失败,1=成功
|
||||||
|
CallTime time.Time `db:"call_time"` // 调用时间
|
||||||
|
ResponseTime sql.NullInt64 `db:"response_time"` // 响应耗时(毫秒)
|
||||||
|
CostPrice float64 `db:"cost_price"` // 本次调用成本(元)
|
||||||
|
ErrorCode sql.NullString `db:"error_code"` // 错误码
|
||||||
|
ErrorMessage sql.NullString `db:"error_message"` // 错误信息
|
||||||
|
RequestParams sql.NullString `db:"request_params"` // 请求参数(JSON)
|
||||||
|
ResponseData sql.NullString `db:"response_data"` // 响应数据(JSON)
|
||||||
|
TransactionId sql.NullString `db:"transaction_id"` // 天远API流水号
|
||||||
|
CreateTime time.Time `db:"create_time"`
|
||||||
|
UpdateTime time.Time `db:"update_time"`
|
||||||
|
DeleteTime sql.NullTime `db:"delete_time"`
|
||||||
|
DelState int64 `db:"del_state"` // 0=未删除,1=已删除
|
||||||
|
Version int64 `db:"version"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func newTianyuanapiCallLogModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultTianyuanapiCallLogModel {
|
||||||
|
return &defaultTianyuanapiCallLogModel{
|
||||||
|
CachedConn: sqlc.NewConn(conn, c),
|
||||||
|
table: "`tianyuanapi_call_log`",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) Insert(ctx context.Context, session sqlx.Session, data *TianyuanapiCallLog) (sql.Result, error) {
|
||||||
|
data.DelState = globalkey.DelStateNo
|
||||||
|
m.insertUUID(data)
|
||||||
|
qncTianyuanapiCallLogIdKey := fmt.Sprintf("%s%v", cacheQncTianyuanapiCallLogIdPrefix, data.Id)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, tianyuanapiCallLogRowsExpectAutoSet)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.FeatureId, data.ApiId, data.OrderId, data.QueryId, data.CallStatus, data.CallTime, data.ResponseTime, data.CostPrice, data.ErrorCode, data.ErrorMessage, data.RequestParams, data.ResponseData, data.TransactionId, data.DeleteTime, data.DelState, data.Version)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.FeatureId, data.ApiId, data.OrderId, data.QueryId, data.CallStatus, data.CallTime, data.ResponseTime, data.CostPrice, data.ErrorCode, data.ErrorMessage, data.RequestParams, data.ResponseData, data.TransactionId, data.DeleteTime, data.DelState, data.Version)
|
||||||
|
}, qncTianyuanapiCallLogIdKey)
|
||||||
|
}
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) insertUUID(data *TianyuanapiCallLog) {
|
||||||
|
t := reflect.TypeOf(data).Elem()
|
||||||
|
v := reflect.ValueOf(data).Elem()
|
||||||
|
for i := 0; i < t.NumField(); i++ {
|
||||||
|
sf := t.Field(i)
|
||||||
|
if sf.Tag.Get("db") == "id" {
|
||||||
|
f := v.Field(i)
|
||||||
|
if f.IsValid() && f.CanSet() && f.Kind() == reflect.String {
|
||||||
|
if f.String() == "" {
|
||||||
|
f.SetString(uuid.NewString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) FindOne(ctx context.Context, id int64) (*TianyuanapiCallLog, error) {
|
||||||
|
qncTianyuanapiCallLogIdKey := fmt.Sprintf("%s%v", cacheQncTianyuanapiCallLogIdPrefix, id)
|
||||||
|
var resp TianyuanapiCallLog
|
||||||
|
err := m.QueryRowCtx(ctx, &resp, qncTianyuanapiCallLogIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", tianyuanapiCallLogRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo)
|
||||||
|
})
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) Update(ctx context.Context, session sqlx.Session, data *TianyuanapiCallLog) (sql.Result, error) {
|
||||||
|
qncTianyuanapiCallLogIdKey := fmt.Sprintf("%s%v", cacheQncTianyuanapiCallLogIdPrefix, data.Id)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, tianyuanapiCallLogRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.FeatureId, data.ApiId, data.OrderId, data.QueryId, data.CallStatus, data.CallTime, data.ResponseTime, data.CostPrice, data.ErrorCode, data.ErrorMessage, data.RequestParams, data.ResponseData, data.TransactionId, data.DeleteTime, data.DelState, data.Version, data.Id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.FeatureId, data.ApiId, data.OrderId, data.QueryId, data.CallStatus, data.CallTime, data.ResponseTime, data.CostPrice, data.ErrorCode, data.ErrorMessage, data.RequestParams, data.ResponseData, data.TransactionId, data.DeleteTime, data.DelState, data.Version, data.Id)
|
||||||
|
}, qncTianyuanapiCallLogIdKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, data *TianyuanapiCallLog) error {
|
||||||
|
|
||||||
|
oldVersion := data.Version
|
||||||
|
data.Version += 1
|
||||||
|
|
||||||
|
var sqlResult sql.Result
|
||||||
|
var err error
|
||||||
|
|
||||||
|
qncTianyuanapiCallLogIdKey := fmt.Sprintf("%s%v", cacheQncTianyuanapiCallLogIdPrefix, data.Id)
|
||||||
|
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, tianyuanapiCallLogRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.FeatureId, data.ApiId, data.OrderId, data.QueryId, data.CallStatus, data.CallTime, data.ResponseTime, data.CostPrice, data.ErrorCode, data.ErrorMessage, data.RequestParams, data.ResponseData, data.TransactionId, data.DeleteTime, data.DelState, data.Version, data.Id, oldVersion)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.FeatureId, data.ApiId, data.OrderId, data.QueryId, data.CallStatus, data.CallTime, data.ResponseTime, data.CostPrice, data.ErrorCode, data.ErrorMessage, data.RequestParams, data.ResponseData, data.TransactionId, data.DeleteTime, data.DelState, data.Version, data.Id, oldVersion)
|
||||||
|
}, qncTianyuanapiCallLogIdKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updateCount, err := sqlResult.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if updateCount == 0 {
|
||||||
|
return ErrNoRowsUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *TianyuanapiCallLog) error {
|
||||||
|
data.DelState = globalkey.DelStateYes
|
||||||
|
data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||||
|
if err := m.UpdateWithVersion(ctx, session, data); err != nil {
|
||||||
|
return errors.Wrapf(errors.New("delete soft failed "), "TianyuanapiCallLogModel delete err : %+v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("IFNULL(SUM(" + field + "),0)")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp float64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("COUNT(" + field + ")")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp int64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*TianyuanapiCallLog, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(tianyuanapiCallLogRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*TianyuanapiCallLog
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*TianyuanapiCallLog, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(tianyuanapiCallLogRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*TianyuanapiCallLog
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*TianyuanapiCallLog, int64, error) {
|
||||||
|
|
||||||
|
total, err := m.FindCount(ctx, builder, "id")
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns(tianyuanapiCallLogRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*TianyuanapiCallLog
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, total, nil
|
||||||
|
default:
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*TianyuanapiCallLog, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(tianyuanapiCallLogRows)
|
||||||
|
|
||||||
|
if preMinId > 0 {
|
||||||
|
builder = builder.Where(" id < ? ", preMinId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*TianyuanapiCallLog
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*TianyuanapiCallLog, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(tianyuanapiCallLogRows)
|
||||||
|
|
||||||
|
if preMaxId > 0 {
|
||||||
|
builder = builder.Where(" id > ? ", preMaxId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*TianyuanapiCallLog
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error {
|
||||||
|
|
||||||
|
return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||||
|
return fn(ctx, session)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) SelectBuilder() squirrel.SelectBuilder {
|
||||||
|
return squirrel.Select().From(m.table)
|
||||||
|
}
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) Delete(ctx context.Context, session sqlx.Session, id int64) error {
|
||||||
|
qncTianyuanapiCallLogIdKey := fmt.Sprintf("%s%v", cacheQncTianyuanapiCallLogIdPrefix, id)
|
||||||
|
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, id)
|
||||||
|
}, qncTianyuanapiCallLogIdKey)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) formatPrimary(primary interface{}) string {
|
||||||
|
return fmt.Sprintf("%s%v", cacheQncTianyuanapiCallLogIdPrefix, primary)
|
||||||
|
}
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", tianyuanapiCallLogRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultTianyuanapiCallLogModel) tableName() string {
|
||||||
|
return m.table
|
||||||
|
}
|
||||||
27
app/main/model/userFeatureWhitelistModel.go
Normal file
27
app/main/model/userFeatureWhitelistModel.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ UserFeatureWhitelistModel = (*customUserFeatureWhitelistModel)(nil)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// UserFeatureWhitelistModel is an interface to be customized, add more methods here,
|
||||||
|
// and implement the added methods in customUserFeatureWhitelistModel.
|
||||||
|
UserFeatureWhitelistModel interface {
|
||||||
|
userFeatureWhitelistModel
|
||||||
|
}
|
||||||
|
|
||||||
|
customUserFeatureWhitelistModel struct {
|
||||||
|
*defaultUserFeatureWhitelistModel
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewUserFeatureWhitelistModel returns a model for the database table.
|
||||||
|
func NewUserFeatureWhitelistModel(conn sqlx.SqlConn, c cache.CacheConf) UserFeatureWhitelistModel {
|
||||||
|
return &customUserFeatureWhitelistModel{
|
||||||
|
defaultUserFeatureWhitelistModel: newUserFeatureWhitelistModel(conn, c),
|
||||||
|
}
|
||||||
|
}
|
||||||
432
app/main/model/userFeatureWhitelistModel_gen.go
Normal file
432
app/main/model/userFeatureWhitelistModel_gen.go
Normal file
@@ -0,0 +1,432 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT!
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"github.com/zeromicro/go-zero/core/stringx"
|
||||||
|
"qnc-server/common/globalkey"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
userFeatureWhitelistFieldNames = builder.RawFieldNames(&UserFeatureWhitelist{})
|
||||||
|
userFeatureWhitelistRows = strings.Join(userFeatureWhitelistFieldNames, ",")
|
||||||
|
userFeatureWhitelistRowsExpectAutoSet = strings.Join(stringx.Remove(userFeatureWhitelistFieldNames, "`create_time`", "`update_time`"), ",")
|
||||||
|
userFeatureWhitelistRowsWithPlaceHolder = strings.Join(stringx.Remove(userFeatureWhitelistFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||||||
|
|
||||||
|
cacheQncUserFeatureWhitelistIdPrefix = "cache:qnc:userFeatureWhitelist:id:"
|
||||||
|
cacheQncUserFeatureWhitelistIdCardFeatureApiIdDelStatePrefix = "cache:qnc:userFeatureWhitelist:idCard:featureApiId:delState:"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
userFeatureWhitelistModel interface {
|
||||||
|
Insert(ctx context.Context, session sqlx.Session, data *UserFeatureWhitelist) (sql.Result, error)
|
||||||
|
FindOne(ctx context.Context, id string) (*UserFeatureWhitelist, error)
|
||||||
|
FindOneByIdCardFeatureApiIdDelState(ctx context.Context, idCard string, featureApiId string, delState int64) (*UserFeatureWhitelist, error)
|
||||||
|
Update(ctx context.Context, session sqlx.Session, data *UserFeatureWhitelist) (sql.Result, error)
|
||||||
|
UpdateWithVersion(ctx context.Context, session sqlx.Session, data *UserFeatureWhitelist) error
|
||||||
|
Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error
|
||||||
|
SelectBuilder() squirrel.SelectBuilder
|
||||||
|
DeleteSoft(ctx context.Context, session sqlx.Session, data *UserFeatureWhitelist) error
|
||||||
|
FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error)
|
||||||
|
FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error)
|
||||||
|
FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*UserFeatureWhitelist, error)
|
||||||
|
FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*UserFeatureWhitelist, error)
|
||||||
|
FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*UserFeatureWhitelist, int64, error)
|
||||||
|
FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*UserFeatureWhitelist, error)
|
||||||
|
FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*UserFeatureWhitelist, error)
|
||||||
|
Delete(ctx context.Context, session sqlx.Session, id string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultUserFeatureWhitelistModel struct {
|
||||||
|
sqlc.CachedConn
|
||||||
|
table string
|
||||||
|
}
|
||||||
|
|
||||||
|
UserFeatureWhitelist struct {
|
||||||
|
Id string `db:"id"` // UUID主键
|
||||||
|
CreateTime time.Time `db:"create_time"`
|
||||||
|
UpdateTime time.Time `db:"update_time"`
|
||||||
|
DeleteTime sql.NullTime `db:"delete_time"`
|
||||||
|
DelState int64 `db:"del_state"` // 0=未删除,1=已删除
|
||||||
|
Version int64 `db:"version"`
|
||||||
|
IdCard string `db:"id_card"` // 身份证号(查询对象标识)
|
||||||
|
FeatureId string `db:"feature_id"` // Feature的UUID
|
||||||
|
FeatureApiId string `db:"feature_api_id"` // Feature的API标识
|
||||||
|
UserId string `db:"user_id"` // 操作用户ID
|
||||||
|
OrderId sql.NullString `db:"order_id"` // 关联的查询订单ID
|
||||||
|
WhitelistOrderId sql.NullString `db:"whitelist_order_id"` // 关联的白名单订单ID
|
||||||
|
Amount float64 `db:"amount"` // 费用(元)
|
||||||
|
Status int64 `db:"status"` // 状态:1=生效,2=已失效
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func newUserFeatureWhitelistModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultUserFeatureWhitelistModel {
|
||||||
|
return &defaultUserFeatureWhitelistModel{
|
||||||
|
CachedConn: sqlc.NewConn(conn, c),
|
||||||
|
table: "`user_feature_whitelist`",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) Insert(ctx context.Context, session sqlx.Session, data *UserFeatureWhitelist) (sql.Result, error) {
|
||||||
|
data.DelState = globalkey.DelStateNo
|
||||||
|
m.insertUUID(data)
|
||||||
|
qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey := fmt.Sprintf("%s%v:%v:%v", cacheQncUserFeatureWhitelistIdCardFeatureApiIdDelStatePrefix, data.IdCard, data.FeatureApiId, data.DelState)
|
||||||
|
qncUserFeatureWhitelistIdKey := fmt.Sprintf("%s%v", cacheQncUserFeatureWhitelistIdPrefix, data.Id)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, userFeatureWhitelistRowsExpectAutoSet)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.IdCard, data.FeatureId, data.FeatureApiId, data.UserId, data.OrderId, data.WhitelistOrderId, data.Amount, data.Status)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.IdCard, data.FeatureId, data.FeatureApiId, data.UserId, data.OrderId, data.WhitelistOrderId, data.Amount, data.Status)
|
||||||
|
}, qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey, qncUserFeatureWhitelistIdKey)
|
||||||
|
}
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) insertUUID(data *UserFeatureWhitelist) {
|
||||||
|
t := reflect.TypeOf(data).Elem()
|
||||||
|
v := reflect.ValueOf(data).Elem()
|
||||||
|
for i := 0; i < t.NumField(); i++ {
|
||||||
|
sf := t.Field(i)
|
||||||
|
if sf.Tag.Get("db") == "id" {
|
||||||
|
f := v.Field(i)
|
||||||
|
if f.IsValid() && f.CanSet() && f.Kind() == reflect.String {
|
||||||
|
if f.String() == "" {
|
||||||
|
f.SetString(uuid.NewString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindOne(ctx context.Context, id string) (*UserFeatureWhitelist, error) {
|
||||||
|
qncUserFeatureWhitelistIdKey := fmt.Sprintf("%s%v", cacheQncUserFeatureWhitelistIdPrefix, id)
|
||||||
|
var resp UserFeatureWhitelist
|
||||||
|
err := m.QueryRowCtx(ctx, &resp, qncUserFeatureWhitelistIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userFeatureWhitelistRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo)
|
||||||
|
})
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindOneByIdCardFeatureApiIdDelState(ctx context.Context, idCard string, featureApiId string, delState int64) (*UserFeatureWhitelist, error) {
|
||||||
|
qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey := fmt.Sprintf("%s%v:%v:%v", cacheQncUserFeatureWhitelistIdCardFeatureApiIdDelStatePrefix, idCard, featureApiId, delState)
|
||||||
|
var resp UserFeatureWhitelist
|
||||||
|
err := m.QueryRowIndexCtx(ctx, &resp, qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id_card` = ? and `feature_api_id` = ? and `del_state` = ? and del_state = ? limit 1", userFeatureWhitelistRows, m.table)
|
||||||
|
if err := conn.QueryRowCtx(ctx, &resp, query, idCard, featureApiId, delState, globalkey.DelStateNo); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp.Id, nil
|
||||||
|
}, m.queryPrimary)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) Update(ctx context.Context, session sqlx.Session, newData *UserFeatureWhitelist) (sql.Result, error) {
|
||||||
|
data, err := m.FindOne(ctx, newData.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey := fmt.Sprintf("%s%v:%v:%v", cacheQncUserFeatureWhitelistIdCardFeatureApiIdDelStatePrefix, data.IdCard, data.FeatureApiId, data.DelState)
|
||||||
|
qncUserFeatureWhitelistIdKey := fmt.Sprintf("%s%v", cacheQncUserFeatureWhitelistIdPrefix, data.Id)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, userFeatureWhitelistRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.IdCard, newData.FeatureId, newData.FeatureApiId, newData.UserId, newData.OrderId, newData.WhitelistOrderId, newData.Amount, newData.Status, newData.Id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.IdCard, newData.FeatureId, newData.FeatureApiId, newData.UserId, newData.OrderId, newData.WhitelistOrderId, newData.Amount, newData.Status, newData.Id)
|
||||||
|
}, qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey, qncUserFeatureWhitelistIdKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *UserFeatureWhitelist) error {
|
||||||
|
|
||||||
|
oldVersion := newData.Version
|
||||||
|
newData.Version += 1
|
||||||
|
|
||||||
|
var sqlResult sql.Result
|
||||||
|
var err error
|
||||||
|
|
||||||
|
data, err := m.FindOne(ctx, newData.Id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey := fmt.Sprintf("%s%v:%v:%v", cacheQncUserFeatureWhitelistIdCardFeatureApiIdDelStatePrefix, data.IdCard, data.FeatureApiId, data.DelState)
|
||||||
|
qncUserFeatureWhitelistIdKey := fmt.Sprintf("%s%v", cacheQncUserFeatureWhitelistIdPrefix, data.Id)
|
||||||
|
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, userFeatureWhitelistRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.IdCard, newData.FeatureId, newData.FeatureApiId, newData.UserId, newData.OrderId, newData.WhitelistOrderId, newData.Amount, newData.Status, newData.Id, oldVersion)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.IdCard, newData.FeatureId, newData.FeatureApiId, newData.UserId, newData.OrderId, newData.WhitelistOrderId, newData.Amount, newData.Status, newData.Id, oldVersion)
|
||||||
|
}, qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey, qncUserFeatureWhitelistIdKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updateCount, err := sqlResult.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if updateCount == 0 {
|
||||||
|
return ErrNoRowsUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *UserFeatureWhitelist) error {
|
||||||
|
data.DelState = globalkey.DelStateYes
|
||||||
|
data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||||
|
if err := m.UpdateWithVersion(ctx, session, data); err != nil {
|
||||||
|
return errors.Wrapf(errors.New("delete soft failed "), "UserFeatureWhitelistModel delete err : %+v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("IFNULL(SUM(" + field + "),0)")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp float64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("COUNT(" + field + ")")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp int64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*UserFeatureWhitelist, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(userFeatureWhitelistRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*UserFeatureWhitelist
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*UserFeatureWhitelist, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(userFeatureWhitelistRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*UserFeatureWhitelist
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*UserFeatureWhitelist, int64, error) {
|
||||||
|
|
||||||
|
total, err := m.FindCount(ctx, builder, "id")
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns(userFeatureWhitelistRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*UserFeatureWhitelist
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, total, nil
|
||||||
|
default:
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*UserFeatureWhitelist, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(userFeatureWhitelistRows)
|
||||||
|
|
||||||
|
if preMinId > 0 {
|
||||||
|
builder = builder.Where(" id < ? ", preMinId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*UserFeatureWhitelist
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*UserFeatureWhitelist, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(userFeatureWhitelistRows)
|
||||||
|
|
||||||
|
if preMaxId > 0 {
|
||||||
|
builder = builder.Where(" id > ? ", preMaxId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*UserFeatureWhitelist
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error {
|
||||||
|
|
||||||
|
return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||||
|
return fn(ctx, session)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) SelectBuilder() squirrel.SelectBuilder {
|
||||||
|
return squirrel.Select().From(m.table)
|
||||||
|
}
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) Delete(ctx context.Context, session sqlx.Session, id string) error {
|
||||||
|
data, err := m.FindOne(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey := fmt.Sprintf("%s%v:%v:%v", cacheQncUserFeatureWhitelistIdCardFeatureApiIdDelStatePrefix, data.IdCard, data.FeatureApiId, data.DelState)
|
||||||
|
qncUserFeatureWhitelistIdKey := fmt.Sprintf("%s%v", cacheQncUserFeatureWhitelistIdPrefix, id)
|
||||||
|
_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, id)
|
||||||
|
}, qncUserFeatureWhitelistIdCardFeatureApiIdDelStateKey, qncUserFeatureWhitelistIdKey)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) formatPrimary(primary interface{}) string {
|
||||||
|
return fmt.Sprintf("%s%v", cacheQncUserFeatureWhitelistIdPrefix, primary)
|
||||||
|
}
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", userFeatureWhitelistRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultUserFeatureWhitelistModel) tableName() string {
|
||||||
|
return m.table
|
||||||
|
}
|
||||||
27
app/main/model/whitelistOrderItemModel.go
Normal file
27
app/main/model/whitelistOrderItemModel.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ WhitelistOrderItemModel = (*customWhitelistOrderItemModel)(nil)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// WhitelistOrderItemModel is an interface to be customized, add more methods here,
|
||||||
|
// and implement the added methods in customWhitelistOrderItemModel.
|
||||||
|
WhitelistOrderItemModel interface {
|
||||||
|
whitelistOrderItemModel
|
||||||
|
}
|
||||||
|
|
||||||
|
customWhitelistOrderItemModel struct {
|
||||||
|
*defaultWhitelistOrderItemModel
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewWhitelistOrderItemModel returns a model for the database table.
|
||||||
|
func NewWhitelistOrderItemModel(conn sqlx.SqlConn, c cache.CacheConf) WhitelistOrderItemModel {
|
||||||
|
return &customWhitelistOrderItemModel{
|
||||||
|
defaultWhitelistOrderItemModel: newWhitelistOrderItemModel(conn, c),
|
||||||
|
}
|
||||||
|
}
|
||||||
390
app/main/model/whitelistOrderItemModel_gen.go
Normal file
390
app/main/model/whitelistOrderItemModel_gen.go
Normal file
@@ -0,0 +1,390 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT!
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"github.com/zeromicro/go-zero/core/stringx"
|
||||||
|
"qnc-server/common/globalkey"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
whitelistOrderItemFieldNames = builder.RawFieldNames(&WhitelistOrderItem{})
|
||||||
|
whitelistOrderItemRows = strings.Join(whitelistOrderItemFieldNames, ",")
|
||||||
|
whitelistOrderItemRowsExpectAutoSet = strings.Join(stringx.Remove(whitelistOrderItemFieldNames, "`create_time`", "`update_time`"), ",")
|
||||||
|
whitelistOrderItemRowsWithPlaceHolder = strings.Join(stringx.Remove(whitelistOrderItemFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||||||
|
|
||||||
|
cacheQncWhitelistOrderItemIdPrefix = "cache:qnc:whitelistOrderItem:id:"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
whitelistOrderItemModel interface {
|
||||||
|
Insert(ctx context.Context, session sqlx.Session, data *WhitelistOrderItem) (sql.Result, error)
|
||||||
|
FindOne(ctx context.Context, id string) (*WhitelistOrderItem, error)
|
||||||
|
Update(ctx context.Context, session sqlx.Session, data *WhitelistOrderItem) (sql.Result, error)
|
||||||
|
UpdateWithVersion(ctx context.Context, session sqlx.Session, data *WhitelistOrderItem) error
|
||||||
|
Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error
|
||||||
|
SelectBuilder() squirrel.SelectBuilder
|
||||||
|
DeleteSoft(ctx context.Context, session sqlx.Session, data *WhitelistOrderItem) error
|
||||||
|
FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error)
|
||||||
|
FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error)
|
||||||
|
FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*WhitelistOrderItem, error)
|
||||||
|
FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*WhitelistOrderItem, error)
|
||||||
|
FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*WhitelistOrderItem, int64, error)
|
||||||
|
FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*WhitelistOrderItem, error)
|
||||||
|
FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*WhitelistOrderItem, error)
|
||||||
|
Delete(ctx context.Context, session sqlx.Session, id string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultWhitelistOrderItemModel struct {
|
||||||
|
sqlc.CachedConn
|
||||||
|
table string
|
||||||
|
}
|
||||||
|
|
||||||
|
WhitelistOrderItem struct {
|
||||||
|
Id string `db:"id"` // UUID主键
|
||||||
|
CreateTime time.Time `db:"create_time"`
|
||||||
|
UpdateTime time.Time `db:"update_time"`
|
||||||
|
DeleteTime sql.NullTime `db:"delete_time"`
|
||||||
|
DelState int64 `db:"del_state"` // 0=未删除,1=已删除
|
||||||
|
Version int64 `db:"version"`
|
||||||
|
OrderId string `db:"order_id"` // 订单ID(关联whitelist_order.id)
|
||||||
|
FeatureId string `db:"feature_id"` // Feature的UUID
|
||||||
|
FeatureApiId string `db:"feature_api_id"` // Feature的API标识
|
||||||
|
FeatureName string `db:"feature_name"` // Feature名称
|
||||||
|
Price float64 `db:"price"` // 单价(元)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func newWhitelistOrderItemModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultWhitelistOrderItemModel {
|
||||||
|
return &defaultWhitelistOrderItemModel{
|
||||||
|
CachedConn: sqlc.NewConn(conn, c),
|
||||||
|
table: "`whitelist_order_item`",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) Insert(ctx context.Context, session sqlx.Session, data *WhitelistOrderItem) (sql.Result, error) {
|
||||||
|
data.DelState = globalkey.DelStateNo
|
||||||
|
m.insertUUID(data)
|
||||||
|
qncWhitelistOrderItemIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderItemIdPrefix, data.Id)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, whitelistOrderItemRowsExpectAutoSet)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.OrderId, data.FeatureId, data.FeatureApiId, data.FeatureName, data.Price)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.OrderId, data.FeatureId, data.FeatureApiId, data.FeatureName, data.Price)
|
||||||
|
}, qncWhitelistOrderItemIdKey)
|
||||||
|
}
|
||||||
|
func (m *defaultWhitelistOrderItemModel) insertUUID(data *WhitelistOrderItem) {
|
||||||
|
t := reflect.TypeOf(data).Elem()
|
||||||
|
v := reflect.ValueOf(data).Elem()
|
||||||
|
for i := 0; i < t.NumField(); i++ {
|
||||||
|
sf := t.Field(i)
|
||||||
|
if sf.Tag.Get("db") == "id" {
|
||||||
|
f := v.Field(i)
|
||||||
|
if f.IsValid() && f.CanSet() && f.Kind() == reflect.String {
|
||||||
|
if f.String() == "" {
|
||||||
|
f.SetString(uuid.NewString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) FindOne(ctx context.Context, id string) (*WhitelistOrderItem, error) {
|
||||||
|
qncWhitelistOrderItemIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderItemIdPrefix, id)
|
||||||
|
var resp WhitelistOrderItem
|
||||||
|
err := m.QueryRowCtx(ctx, &resp, qncWhitelistOrderItemIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", whitelistOrderItemRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo)
|
||||||
|
})
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) Update(ctx context.Context, session sqlx.Session, data *WhitelistOrderItem) (sql.Result, error) {
|
||||||
|
qncWhitelistOrderItemIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderItemIdPrefix, data.Id)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, whitelistOrderItemRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.OrderId, data.FeatureId, data.FeatureApiId, data.FeatureName, data.Price, data.Id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.OrderId, data.FeatureId, data.FeatureApiId, data.FeatureName, data.Price, data.Id)
|
||||||
|
}, qncWhitelistOrderItemIdKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, data *WhitelistOrderItem) error {
|
||||||
|
|
||||||
|
oldVersion := data.Version
|
||||||
|
data.Version += 1
|
||||||
|
|
||||||
|
var sqlResult sql.Result
|
||||||
|
var err error
|
||||||
|
|
||||||
|
qncWhitelistOrderItemIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderItemIdPrefix, data.Id)
|
||||||
|
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, whitelistOrderItemRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.OrderId, data.FeatureId, data.FeatureApiId, data.FeatureName, data.Price, data.Id, oldVersion)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.DeleteTime, data.DelState, data.Version, data.OrderId, data.FeatureId, data.FeatureApiId, data.FeatureName, data.Price, data.Id, oldVersion)
|
||||||
|
}, qncWhitelistOrderItemIdKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updateCount, err := sqlResult.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if updateCount == 0 {
|
||||||
|
return ErrNoRowsUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *WhitelistOrderItem) error {
|
||||||
|
data.DelState = globalkey.DelStateYes
|
||||||
|
data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||||
|
if err := m.UpdateWithVersion(ctx, session, data); err != nil {
|
||||||
|
return errors.Wrapf(errors.New("delete soft failed "), "WhitelistOrderItemModel delete err : %+v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("IFNULL(SUM(" + field + "),0)")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp float64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("COUNT(" + field + ")")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp int64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*WhitelistOrderItem, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderItemRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrderItem
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*WhitelistOrderItem, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderItemRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrderItem
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*WhitelistOrderItem, int64, error) {
|
||||||
|
|
||||||
|
total, err := m.FindCount(ctx, builder, "id")
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderItemRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrderItem
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, total, nil
|
||||||
|
default:
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*WhitelistOrderItem, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderItemRows)
|
||||||
|
|
||||||
|
if preMinId > 0 {
|
||||||
|
builder = builder.Where(" id < ? ", preMinId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrderItem
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*WhitelistOrderItem, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderItemRows)
|
||||||
|
|
||||||
|
if preMaxId > 0 {
|
||||||
|
builder = builder.Where(" id > ? ", preMaxId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrderItem
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error {
|
||||||
|
|
||||||
|
return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||||
|
return fn(ctx, session)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) SelectBuilder() squirrel.SelectBuilder {
|
||||||
|
return squirrel.Select().From(m.table)
|
||||||
|
}
|
||||||
|
func (m *defaultWhitelistOrderItemModel) Delete(ctx context.Context, session sqlx.Session, id string) error {
|
||||||
|
qncWhitelistOrderItemIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderItemIdPrefix, id)
|
||||||
|
_, err := m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, id)
|
||||||
|
}, qncWhitelistOrderItemIdKey)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
func (m *defaultWhitelistOrderItemModel) formatPrimary(primary interface{}) string {
|
||||||
|
return fmt.Sprintf("%s%v", cacheQncWhitelistOrderItemIdPrefix, primary)
|
||||||
|
}
|
||||||
|
func (m *defaultWhitelistOrderItemModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", whitelistOrderItemRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderItemModel) tableName() string {
|
||||||
|
return m.table
|
||||||
|
}
|
||||||
27
app/main/model/whitelistOrderModel.go
Normal file
27
app/main/model/whitelistOrderModel.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ WhitelistOrderModel = (*customWhitelistOrderModel)(nil)
|
||||||
|
|
||||||
|
type (
|
||||||
|
// WhitelistOrderModel is an interface to be customized, add more methods here,
|
||||||
|
// and implement the added methods in customWhitelistOrderModel.
|
||||||
|
WhitelistOrderModel interface {
|
||||||
|
whitelistOrderModel
|
||||||
|
}
|
||||||
|
|
||||||
|
customWhitelistOrderModel struct {
|
||||||
|
*defaultWhitelistOrderModel
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewWhitelistOrderModel returns a model for the database table.
|
||||||
|
func NewWhitelistOrderModel(conn sqlx.SqlConn, c cache.CacheConf) WhitelistOrderModel {
|
||||||
|
return &customWhitelistOrderModel{
|
||||||
|
defaultWhitelistOrderModel: newWhitelistOrderModel(conn, c),
|
||||||
|
}
|
||||||
|
}
|
||||||
433
app/main/model/whitelistOrderModel_gen.go
Normal file
433
app/main/model/whitelistOrderModel_gen.go
Normal file
@@ -0,0 +1,433 @@
|
|||||||
|
// Code generated by goctl. DO NOT EDIT!
|
||||||
|
|
||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Masterminds/squirrel"
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/builder"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlc"
|
||||||
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
||||||
|
"github.com/zeromicro/go-zero/core/stringx"
|
||||||
|
"qnc-server/common/globalkey"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
whitelistOrderFieldNames = builder.RawFieldNames(&WhitelistOrder{})
|
||||||
|
whitelistOrderRows = strings.Join(whitelistOrderFieldNames, ",")
|
||||||
|
whitelistOrderRowsExpectAutoSet = strings.Join(stringx.Remove(whitelistOrderFieldNames, "`create_time`", "`update_time`"), ",")
|
||||||
|
whitelistOrderRowsWithPlaceHolder = strings.Join(stringx.Remove(whitelistOrderFieldNames, "`id`", "`create_time`", "`update_time`"), "=?,") + "=?"
|
||||||
|
|
||||||
|
cacheQncWhitelistOrderIdPrefix = "cache:qnc:whitelistOrder:id:"
|
||||||
|
cacheQncWhitelistOrderOrderNoPrefix = "cache:qnc:whitelistOrder:orderNo:"
|
||||||
|
)
|
||||||
|
|
||||||
|
type (
|
||||||
|
whitelistOrderModel interface {
|
||||||
|
Insert(ctx context.Context, session sqlx.Session, data *WhitelistOrder) (sql.Result, error)
|
||||||
|
FindOne(ctx context.Context, id string) (*WhitelistOrder, error)
|
||||||
|
FindOneByOrderNo(ctx context.Context, orderNo string) (*WhitelistOrder, error)
|
||||||
|
Update(ctx context.Context, session sqlx.Session, data *WhitelistOrder) (sql.Result, error)
|
||||||
|
UpdateWithVersion(ctx context.Context, session sqlx.Session, data *WhitelistOrder) error
|
||||||
|
Trans(ctx context.Context, fn func(context context.Context, session sqlx.Session) error) error
|
||||||
|
SelectBuilder() squirrel.SelectBuilder
|
||||||
|
DeleteSoft(ctx context.Context, session sqlx.Session, data *WhitelistOrder) error
|
||||||
|
FindSum(ctx context.Context, sumBuilder squirrel.SelectBuilder, field string) (float64, error)
|
||||||
|
FindCount(ctx context.Context, countBuilder squirrel.SelectBuilder, field string) (int64, error)
|
||||||
|
FindAll(ctx context.Context, rowBuilder squirrel.SelectBuilder, orderBy string) ([]*WhitelistOrder, error)
|
||||||
|
FindPageListByPage(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*WhitelistOrder, error)
|
||||||
|
FindPageListByPageWithTotal(ctx context.Context, rowBuilder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*WhitelistOrder, int64, error)
|
||||||
|
FindPageListByIdDESC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*WhitelistOrder, error)
|
||||||
|
FindPageListByIdASC(ctx context.Context, rowBuilder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*WhitelistOrder, error)
|
||||||
|
Delete(ctx context.Context, session sqlx.Session, id string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultWhitelistOrderModel struct {
|
||||||
|
sqlc.CachedConn
|
||||||
|
table string
|
||||||
|
}
|
||||||
|
|
||||||
|
WhitelistOrder struct {
|
||||||
|
Id string `db:"id"` // UUID主键
|
||||||
|
CreateTime time.Time `db:"create_time"`
|
||||||
|
UpdateTime time.Time `db:"update_time"`
|
||||||
|
DeleteTime sql.NullTime `db:"delete_time"`
|
||||||
|
DelState int64 `db:"del_state"` // 0=未删除,1=已删除
|
||||||
|
Version int64 `db:"version"`
|
||||||
|
OrderNo string `db:"order_no"` // 订单号(唯一)
|
||||||
|
UserId string `db:"user_id"` // 用户ID(代理的user_id)
|
||||||
|
IdCard string `db:"id_card"` // 身份证号
|
||||||
|
TotalAmount float64 `db:"total_amount"` // 总金额(元)
|
||||||
|
Status int64 `db:"status"` // 1=待支付,2=已支付,3=已取消
|
||||||
|
PaymentMethod sql.NullString `db:"payment_method"` // 支付方式:wechat, alipay, appleiap等
|
||||||
|
PaymentPlatform sql.NullString `db:"payment_platform"` // 支付平台
|
||||||
|
PlatformOrderId sql.NullString `db:"platform_order_id"` // 支付平台订单号
|
||||||
|
PayTime sql.NullTime `db:"pay_time"` // 支付时间
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func newWhitelistOrderModel(conn sqlx.SqlConn, c cache.CacheConf) *defaultWhitelistOrderModel {
|
||||||
|
return &defaultWhitelistOrderModel{
|
||||||
|
CachedConn: sqlc.NewConn(conn, c),
|
||||||
|
table: "`whitelist_order`",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) Insert(ctx context.Context, session sqlx.Session, data *WhitelistOrder) (sql.Result, error) {
|
||||||
|
data.DelState = globalkey.DelStateNo
|
||||||
|
m.insertUUID(data)
|
||||||
|
qncWhitelistOrderIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderIdPrefix, data.Id)
|
||||||
|
qncWhitelistOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderOrderNoPrefix, data.OrderNo)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("insert into %s (%s) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", m.table, whitelistOrderRowsExpectAutoSet)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.OrderNo, data.UserId, data.IdCard, data.TotalAmount, data.Status, data.PaymentMethod, data.PaymentPlatform, data.PlatformOrderId, data.PayTime)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, data.Id, data.DeleteTime, data.DelState, data.Version, data.OrderNo, data.UserId, data.IdCard, data.TotalAmount, data.Status, data.PaymentMethod, data.PaymentPlatform, data.PlatformOrderId, data.PayTime)
|
||||||
|
}, qncWhitelistOrderIdKey, qncWhitelistOrderOrderNoKey)
|
||||||
|
}
|
||||||
|
func (m *defaultWhitelistOrderModel) insertUUID(data *WhitelistOrder) {
|
||||||
|
t := reflect.TypeOf(data).Elem()
|
||||||
|
v := reflect.ValueOf(data).Elem()
|
||||||
|
for i := 0; i < t.NumField(); i++ {
|
||||||
|
sf := t.Field(i)
|
||||||
|
if sf.Tag.Get("db") == "id" {
|
||||||
|
f := v.Field(i)
|
||||||
|
if f.IsValid() && f.CanSet() && f.Kind() == reflect.String {
|
||||||
|
if f.String() == "" {
|
||||||
|
f.SetString(uuid.NewString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindOne(ctx context.Context, id string) (*WhitelistOrder, error) {
|
||||||
|
qncWhitelistOrderIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderIdPrefix, id)
|
||||||
|
var resp WhitelistOrder
|
||||||
|
err := m.QueryRowCtx(ctx, &resp, qncWhitelistOrderIdKey, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", whitelistOrderRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, id, globalkey.DelStateNo)
|
||||||
|
})
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindOneByOrderNo(ctx context.Context, orderNo string) (*WhitelistOrder, error) {
|
||||||
|
qncWhitelistOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderOrderNoPrefix, orderNo)
|
||||||
|
var resp WhitelistOrder
|
||||||
|
err := m.QueryRowIndexCtx(ctx, &resp, qncWhitelistOrderOrderNoKey, m.formatPrimary, func(ctx context.Context, conn sqlx.SqlConn, v interface{}) (i interface{}, e error) {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `order_no` = ? and del_state = ? limit 1", whitelistOrderRows, m.table)
|
||||||
|
if err := conn.QueryRowCtx(ctx, &resp, query, orderNo, globalkey.DelStateNo); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp.Id, nil
|
||||||
|
}, m.queryPrimary)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return &resp, nil
|
||||||
|
case sqlc.ErrNotFound:
|
||||||
|
return nil, ErrNotFound
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) Update(ctx context.Context, session sqlx.Session, newData *WhitelistOrder) (sql.Result, error) {
|
||||||
|
data, err := m.FindOne(ctx, newData.Id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
qncWhitelistOrderIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderIdPrefix, data.Id)
|
||||||
|
qncWhitelistOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderOrderNoPrefix, data.OrderNo)
|
||||||
|
return m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ?", m.table, whitelistOrderRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.OrderNo, newData.UserId, newData.IdCard, newData.TotalAmount, newData.Status, newData.PaymentMethod, newData.PaymentPlatform, newData.PlatformOrderId, newData.PayTime, newData.Id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.OrderNo, newData.UserId, newData.IdCard, newData.TotalAmount, newData.Status, newData.PaymentMethod, newData.PaymentPlatform, newData.PlatformOrderId, newData.PayTime, newData.Id)
|
||||||
|
}, qncWhitelistOrderIdKey, qncWhitelistOrderOrderNoKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) UpdateWithVersion(ctx context.Context, session sqlx.Session, newData *WhitelistOrder) error {
|
||||||
|
|
||||||
|
oldVersion := newData.Version
|
||||||
|
newData.Version += 1
|
||||||
|
|
||||||
|
var sqlResult sql.Result
|
||||||
|
var err error
|
||||||
|
|
||||||
|
data, err := m.FindOne(ctx, newData.Id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
qncWhitelistOrderIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderIdPrefix, data.Id)
|
||||||
|
qncWhitelistOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderOrderNoPrefix, data.OrderNo)
|
||||||
|
sqlResult, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("update %s set %s where `id` = ? and version = ? ", m.table, whitelistOrderRowsWithPlaceHolder)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.OrderNo, newData.UserId, newData.IdCard, newData.TotalAmount, newData.Status, newData.PaymentMethod, newData.PaymentPlatform, newData.PlatformOrderId, newData.PayTime, newData.Id, oldVersion)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, newData.DeleteTime, newData.DelState, newData.Version, newData.OrderNo, newData.UserId, newData.IdCard, newData.TotalAmount, newData.Status, newData.PaymentMethod, newData.PaymentPlatform, newData.PlatformOrderId, newData.PayTime, newData.Id, oldVersion)
|
||||||
|
}, qncWhitelistOrderIdKey, qncWhitelistOrderOrderNoKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
updateCount, err := sqlResult.RowsAffected()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if updateCount == 0 {
|
||||||
|
return ErrNoRowsUpdate
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) DeleteSoft(ctx context.Context, session sqlx.Session, data *WhitelistOrder) error {
|
||||||
|
data.DelState = globalkey.DelStateYes
|
||||||
|
data.DeleteTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||||
|
if err := m.UpdateWithVersion(ctx, session, data); err != nil {
|
||||||
|
return errors.Wrapf(errors.New("delete soft failed "), "WhitelistOrderModel delete err : %+v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindSum(ctx context.Context, builder squirrel.SelectBuilder, field string) (float64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindSum Least One Field"), "FindSum Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("IFNULL(SUM(" + field + "),0)")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp float64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindCount(ctx context.Context, builder squirrel.SelectBuilder, field string) (int64, error) {
|
||||||
|
|
||||||
|
if len(field) == 0 {
|
||||||
|
return 0, errors.Wrapf(errors.New("FindCount Least One Field"), "FindCount Least One Field")
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns("COUNT(" + field + ")")
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp int64
|
||||||
|
err = m.QueryRowNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindAll(ctx context.Context, builder squirrel.SelectBuilder, orderBy string) ([]*WhitelistOrder, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrder
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindPageListByPage(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*WhitelistOrder, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrder
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindPageListByPageWithTotal(ctx context.Context, builder squirrel.SelectBuilder, page, pageSize int64, orderBy string) ([]*WhitelistOrder, int64, error) {
|
||||||
|
|
||||||
|
total, err := m.FindCount(ctx, builder, "id")
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderRows)
|
||||||
|
|
||||||
|
if orderBy == "" {
|
||||||
|
builder = builder.OrderBy("id DESC")
|
||||||
|
} else {
|
||||||
|
builder = builder.OrderBy(orderBy)
|
||||||
|
}
|
||||||
|
|
||||||
|
if page < 1 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
offset := (page - 1) * pageSize
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).Offset(uint64(offset)).Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrder
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, total, nil
|
||||||
|
default:
|
||||||
|
return nil, total, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindPageListByIdDESC(ctx context.Context, builder squirrel.SelectBuilder, preMinId, pageSize int64) ([]*WhitelistOrder, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderRows)
|
||||||
|
|
||||||
|
if preMinId > 0 {
|
||||||
|
builder = builder.Where(" id < ? ", preMinId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id DESC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrder
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) FindPageListByIdASC(ctx context.Context, builder squirrel.SelectBuilder, preMaxId, pageSize int64) ([]*WhitelistOrder, error) {
|
||||||
|
|
||||||
|
builder = builder.Columns(whitelistOrderRows)
|
||||||
|
|
||||||
|
if preMaxId > 0 {
|
||||||
|
builder = builder.Where(" id > ? ", preMaxId)
|
||||||
|
}
|
||||||
|
|
||||||
|
query, values, err := builder.Where("del_state = ?", globalkey.DelStateNo).OrderBy("id ASC").Limit(uint64(pageSize)).ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp []*WhitelistOrder
|
||||||
|
err = m.QueryRowsNoCacheCtx(ctx, &resp, query, values...)
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return resp, nil
|
||||||
|
default:
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) Trans(ctx context.Context, fn func(ctx context.Context, session sqlx.Session) error) error {
|
||||||
|
|
||||||
|
return m.TransactCtx(ctx, func(ctx context.Context, session sqlx.Session) error {
|
||||||
|
return fn(ctx, session)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) SelectBuilder() squirrel.SelectBuilder {
|
||||||
|
return squirrel.Select().From(m.table)
|
||||||
|
}
|
||||||
|
func (m *defaultWhitelistOrderModel) Delete(ctx context.Context, session sqlx.Session, id string) error {
|
||||||
|
data, err := m.FindOne(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
qncWhitelistOrderIdKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderIdPrefix, id)
|
||||||
|
qncWhitelistOrderOrderNoKey := fmt.Sprintf("%s%v", cacheQncWhitelistOrderOrderNoPrefix, data.OrderNo)
|
||||||
|
_, err = m.ExecCtx(ctx, func(ctx context.Context, conn sqlx.SqlConn) (result sql.Result, err error) {
|
||||||
|
query := fmt.Sprintf("delete from %s where `id` = ?", m.table)
|
||||||
|
if session != nil {
|
||||||
|
return session.ExecCtx(ctx, query, id)
|
||||||
|
}
|
||||||
|
return conn.ExecCtx(ctx, query, id)
|
||||||
|
}, qncWhitelistOrderIdKey, qncWhitelistOrderOrderNoKey)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
func (m *defaultWhitelistOrderModel) formatPrimary(primary interface{}) string {
|
||||||
|
return fmt.Sprintf("%s%v", cacheQncWhitelistOrderIdPrefix, primary)
|
||||||
|
}
|
||||||
|
func (m *defaultWhitelistOrderModel) queryPrimary(ctx context.Context, conn sqlx.SqlConn, v, primary interface{}) error {
|
||||||
|
query := fmt.Sprintf("select %s from %s where `id` = ? and del_state = ? limit 1", whitelistOrderRows, m.table)
|
||||||
|
return conn.QueryRowCtx(ctx, v, query, primary, globalkey.DelStateNo)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *defaultWhitelistOrderModel) tableName() string {
|
||||||
|
return m.table
|
||||||
|
}
|
||||||
@@ -10,6 +10,14 @@ $HOME_DIR = Join-Path $PSScriptRoot "..\template"
|
|||||||
|
|
||||||
# 表名列表
|
# 表名列表
|
||||||
$tables = @(
|
$tables = @(
|
||||||
|
# ============================================
|
||||||
|
# 统计/白名单/成本价 同步用(执行 sync_whitelist_cost_tables.sql 后再生成)
|
||||||
|
# ============================================
|
||||||
|
"feature",
|
||||||
|
"tianyuanapi_call_log",
|
||||||
|
"user_feature_whitelist",
|
||||||
|
"whitelist_order",
|
||||||
|
"whitelist_order_item"
|
||||||
# ============================================
|
# ============================================
|
||||||
# 新代理系统表
|
# 新代理系统表
|
||||||
# ============================================
|
# ============================================
|
||||||
@@ -28,7 +36,7 @@ $tables = @(
|
|||||||
# "admin_user_role",
|
# "admin_user_role",
|
||||||
# "agent",
|
# "agent",
|
||||||
# "agent_commission",
|
# "agent_commission",
|
||||||
"agent_config"
|
# "agent_config"
|
||||||
# "agent_freeze_task",
|
# "agent_freeze_task",
|
||||||
# "agent_invite_code",
|
# "agent_invite_code",
|
||||||
# "agent_invite_code_usage",
|
# "agent_invite_code_usage",
|
||||||
@@ -62,7 +70,7 @@ $tables = @(
|
|||||||
# 为每个表生成模型
|
# 为每个表生成模型
|
||||||
foreach ($table in $tables) {
|
foreach ($table in $tables) {
|
||||||
Write-Host "正在生成表: $table" -ForegroundColor Green
|
Write-Host "正在生成表: $table" -ForegroundColor Green
|
||||||
goctl model mysql datasource -url="qnc:5vg67b3UNHu8@tcp(127.0.0.1:21001)/qnc" -table="$table" -dir="./model" --home="$HOME_DIR" -cache=true --style=goZero
|
goctl model mysql datasource -url="qnc:5vg67b3UNHu8@tcp(127.0.0.1:21201)/qnc" -table="$table" -dir="./model" --home="$HOME_DIR" -cache=true --style=goZero
|
||||||
|
|
||||||
# 移动生成的文件到目标目录
|
# 移动生成的文件到目标目录
|
||||||
if (Test-Path $OUTPUT_DIR) {
|
if (Test-Path $OUTPUT_DIR) {
|
||||||
|
|||||||
Reference in New Issue
Block a user