Compare commits
5 Commits
de42e69593
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c4cc15f853 | |||
| fd229f0d59 | |||
| 5089b37ef1 | |||
| f31c2d7293 | |||
| 1217ba119b |
@@ -109,7 +109,6 @@ service main {
|
||||
// 代理钱包流水分页查询
|
||||
@handler AdminGetAgentWalletTransactionList
|
||||
get /wallet-transaction/list (AdminGetAgentWalletTransactionListReq) returns (AdminGetAgentWalletTransactionListResp)
|
||||
|
||||
}
|
||||
|
||||
type (
|
||||
@@ -121,7 +120,6 @@ type (
|
||||
Region *string `form:"region,optional"` // 区域(可选)
|
||||
ParentAgentId *int64 `form:"parent_agent_id,optional"` // 上级代理ID(可选)
|
||||
}
|
||||
|
||||
// 代理列表项
|
||||
AgentListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -141,13 +139,11 @@ type (
|
||||
IdCard string `json:"id_card"` // 身份证号
|
||||
RealNameStatus string `json:"real_name_status"` // 实名状态(pending/approved/rejected)
|
||||
}
|
||||
|
||||
// 代理分页查询响应
|
||||
AdminGetAgentListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理推广链接分页查询请求
|
||||
AdminGetAgentLinkListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -156,7 +152,6 @@ type (
|
||||
ProductName *string `form:"product_name,optional"` // 产品名(可选)
|
||||
LinkIdentifier *string `form:"link_identifier,optional"` // 推广码(可选)
|
||||
}
|
||||
|
||||
// 代理推广链接列表项
|
||||
AgentLinkListItem {
|
||||
AgentId int64 `json:"agent_id"` // 代理ID
|
||||
@@ -165,13 +160,11 @@ type (
|
||||
LinkIdentifier string `json:"link_identifier"` // 推广码
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 代理推广链接分页查询响应
|
||||
AdminGetAgentLinkListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentLinkListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理佣金分页查询请求
|
||||
AdminGetAgentCommissionListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -183,7 +176,6 @@ type (
|
||||
CreateTimeStart *string `form:"create_time_start,optional"` // 创建时间开始(可选)
|
||||
CreateTimeEnd *string `form:"create_time_end,optional"` // 创建时间结束(可选)
|
||||
}
|
||||
|
||||
// 代理佣金列表项
|
||||
AgentCommissionListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -194,36 +186,30 @@ type (
|
||||
Status int64 `json:"status"` // 状态
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 代理佣金分页查询响应
|
||||
AdminGetAgentCommissionListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentCommissionListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理佣金状态更新请求
|
||||
AdminUpdateAgentCommissionStatusReq {
|
||||
Id int64 `json:"id"` // 佣金记录ID
|
||||
Status int64 `json:"status"` // 状态:0-已结算,1-冻结中,2-已取消
|
||||
}
|
||||
|
||||
// 代理佣金状态更新响应
|
||||
AdminUpdateAgentCommissionStatusResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
}
|
||||
|
||||
// 批量解冻代理佣金请求
|
||||
AdminBatchUnfreezeAgentCommissionReq {
|
||||
AgentId *int64 `json:"agent_id,optional"` // 代理ID,可选。如果不传则解冻所有冻结中的佣金
|
||||
}
|
||||
|
||||
// 批量解冻代理佣金响应
|
||||
AdminBatchUnfreezeAgentCommissionResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
Count int64 `json:"count"` // 解冻的数量
|
||||
Amount float64 `json:"amount"` // 解冻的总金额
|
||||
}
|
||||
|
||||
// 代理奖励分页查询请求
|
||||
AdminGetAgentRewardListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -232,7 +218,6 @@ type (
|
||||
RelationAgentId *int64 `form:"relation_agent_id,optional"` // 关联代理ID(可选)
|
||||
Type *string `form:"type,optional"` // 奖励类型(可选)
|
||||
}
|
||||
|
||||
// 代理奖励列表项
|
||||
AgentRewardListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -242,13 +227,11 @@ type (
|
||||
Type string `json:"type"` // 奖励类型
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 代理奖励分页查询响应
|
||||
AdminGetAgentRewardListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentRewardListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理提现分页查询请求
|
||||
AdminGetAgentWithdrawalListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -258,7 +241,6 @@ type (
|
||||
WithdrawNo *string `form:"withdraw_no,optional"` // 提现单号(可选)
|
||||
WithdrawType *int64 `form:"withdraw_type,optional"` // 提现类型(可选)1-支付宝,2-银行卡
|
||||
}
|
||||
|
||||
// 代理提现列表项
|
||||
AgentWithdrawalListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -267,6 +249,7 @@ type (
|
||||
Amount float64 `json:"amount"` // 金额
|
||||
ActualAmount float64 `json:"actual_amount"` // 实际到账金额(扣税后)
|
||||
TaxAmount float64 `json:"tax_amount"` // 扣税金额
|
||||
TaxRate float64 `json:"tax_rate"` // 扣税比例,如 0.06 表示 6%
|
||||
Status int64 `json:"status"` // 状态
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户
|
||||
Remark string `json:"remark"` // 备注
|
||||
@@ -276,13 +259,11 @@ type (
|
||||
BankName string `json:"bank_name"` // 开户支行
|
||||
PayeeName string `json:"payee_name"` // 收款人姓名
|
||||
}
|
||||
|
||||
// 代理提现分页查询响应
|
||||
AdminGetAgentWithdrawalListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentWithdrawalListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理抽佣分页查询请求
|
||||
AdminGetAgentCommissionDeductionListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -292,7 +273,6 @@ type (
|
||||
Type *string `form:"type,optional"` // 类型(cost/pricing,可选)
|
||||
Status *int64 `form:"status,optional"` // 状态(可选)
|
||||
}
|
||||
|
||||
// 代理抽佣列表项
|
||||
AgentCommissionDeductionListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -304,13 +284,11 @@ type (
|
||||
Status int64 `json:"status"` // 状态
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 代理抽佣分页查询响应
|
||||
AdminGetAgentCommissionDeductionListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentCommissionDeductionListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 平台抽佣分页查询请求
|
||||
AdminGetAgentPlatformDeductionListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -319,7 +297,6 @@ type (
|
||||
Type *string `form:"type,optional"` // 类型(cost/pricing,可选)
|
||||
Status *int64 `form:"status,optional"` // 状态(可选)
|
||||
}
|
||||
|
||||
// 平台抽佣列表项
|
||||
AgentPlatformDeductionListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -329,13 +306,11 @@ type (
|
||||
Status int64 `json:"status"` // 状态
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 平台抽佣分页查询响应
|
||||
AdminGetAgentPlatformDeductionListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentPlatformDeductionListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理产品配置分页查询请求
|
||||
AdminGetAgentProductionConfigListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -343,13 +318,11 @@ type (
|
||||
ProductName *string `form:"product_name,optional"` // 产品名(可选)
|
||||
Id *int64 `form:"id,optional"` // 配置ID(可选)
|
||||
}
|
||||
|
||||
// 代理产品配置分页查询响应
|
||||
AdminGetAgentProductionConfigListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentProductionConfigItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理产品配置列表项
|
||||
AgentProductionConfigItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -361,7 +334,6 @@ type (
|
||||
OverpricingRatio float64 `json:"overpricing_ratio"` // 超价比例
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 代理产品配置编辑请求
|
||||
AdminUpdateAgentProductionConfigReq {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -371,12 +343,10 @@ type (
|
||||
PricingStandard float64 `json:"pricing_standard"` // 定价标准
|
||||
OverpricingRatio float64 `json:"overpricing_ratio"` // 超价比例
|
||||
}
|
||||
|
||||
// 代理产品配置编辑响应
|
||||
AdminUpdateAgentProductionConfigResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
}
|
||||
|
||||
// 代理会员充值订单分页查询请求
|
||||
AdminGetAgentMembershipRechargeOrderListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -388,7 +358,6 @@ type (
|
||||
Status *string `form:"status,optional"` // 状态(可选)
|
||||
PaymentMethod *string `form:"payment_method,optional"` // 支付方式(可选)
|
||||
}
|
||||
|
||||
// 代理会员充值订单列表项
|
||||
AgentMembershipRechargeOrderListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -402,26 +371,22 @@ type (
|
||||
Status string `json:"status"` // 状态
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 代理会员充值订单分页查询响应
|
||||
AdminGetAgentMembershipRechargeOrderListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentMembershipRechargeOrderListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理会员配置分页查询请求
|
||||
AdminGetAgentMembershipConfigListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
PageSize int64 `form:"pageSize"` // 每页数量
|
||||
LevelName *string `form:"level_name,optional"` // 会员级别名称(可选)
|
||||
}
|
||||
|
||||
// 代理会员配置分页查询响应
|
||||
AdminGetAgentMembershipConfigListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentMembershipConfigListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 代理会员配置列表项
|
||||
AgentMembershipConfigListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -441,7 +406,6 @@ type (
|
||||
PriceIncreaseAmount *float64 `json:"price_increase_amount"` // 在原本成本上加价的金额
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 代理会员配置编辑请求
|
||||
AdminUpdateAgentMembershipConfigReq {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -460,28 +424,23 @@ type (
|
||||
PriceRatio *float64 `json:"price_ratio,optional,omitempty"` // 提价区间收取比例
|
||||
PriceIncreaseAmount *float64 `json:"price_increase_amount,optional,omitempty"` // 在原本成本上加价的金额
|
||||
}
|
||||
|
||||
// 代理会员配置编辑响应
|
||||
AdminUpdateAgentMembershipConfigResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
}
|
||||
|
||||
// 银行卡提现审核请求
|
||||
AdminReviewBankCardWithdrawalReq {
|
||||
WithdrawalId int64 `json:"withdrawal_id"` // 提现记录ID
|
||||
Action int64 `json:"action"` // 操作:1-确认,2-拒绝
|
||||
Remark string `json:"remark"` // 备注(拒绝时必填)
|
||||
TaxRate *float64 `json:"tax_rate,optional"` // 扣税比例,如 0.06 表示 6%,不传则默认 6%
|
||||
}
|
||||
|
||||
// 银行卡提现审核响应
|
||||
AdminReviewBankCardWithdrawalResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
}
|
||||
|
||||
// 获取提现统计数据请求
|
||||
AdminGetWithdrawalStatisticsReq {
|
||||
}
|
||||
|
||||
AdminGetWithdrawalStatisticsReq {}
|
||||
// 获取提现统计数据响应
|
||||
AdminGetWithdrawalStatisticsResp {
|
||||
TotalWithdrawalAmount float64 `json:"total_withdrawal_amount"` // 总提现金额
|
||||
@@ -489,81 +448,63 @@ type (
|
||||
TotalActualAmount float64 `json:"total_actual_amount"` // 总实际到账金额
|
||||
TotalTaxAmount float64 `json:"total_tax_amount"` // 总扣税金额
|
||||
}
|
||||
|
||||
// 获取代理订单统计数据请求
|
||||
AdminGetAgentOrderStatisticsReq {
|
||||
}
|
||||
|
||||
AdminGetAgentOrderStatisticsReq {}
|
||||
// 获取代理订单统计数据响应
|
||||
AdminGetAgentOrderStatisticsResp {
|
||||
TotalAgentOrderCount int64 `json:"total_agent_order_count"` // 总代理订单数
|
||||
TodayAgentOrderCount int64 `json:"today_agent_order_count"` // 今日代理订单数
|
||||
}
|
||||
|
||||
// 获取代理统计数据请求
|
||||
AdminGetAgentStatisticsReq {
|
||||
}
|
||||
|
||||
AdminGetAgentStatisticsReq {}
|
||||
// 获取代理统计数据响应
|
||||
AdminGetAgentStatisticsResp {
|
||||
TotalAgentCount int64 `json:"total_agent_count"` // 总代理数
|
||||
TodayAgentCount int64 `json:"today_agent_count"` // 今日新增代理数
|
||||
}
|
||||
|
||||
// 获取代理链接产品统计请求
|
||||
AdminGetAgentLinkProductStatisticsReq {
|
||||
}
|
||||
|
||||
AdminGetAgentLinkProductStatisticsReq {}
|
||||
// 代理链接产品统计列表项
|
||||
AgentLinkProductStatisticsItem {
|
||||
ProductName string `json:"product_name"` // 产品名称
|
||||
LinkCount int64 `json:"link_count"` // 推广链接数量
|
||||
}
|
||||
|
||||
// 获取代理链接产品统计响应
|
||||
AdminGetAgentLinkProductStatisticsResp {
|
||||
Items []AgentLinkProductStatisticsItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
// 获取代理钱包信息请求
|
||||
AdminGetAgentWalletReq {
|
||||
AgentId int64 `path:"agent_id"` // 代理ID
|
||||
}
|
||||
|
||||
// 获取代理钱包信息响应
|
||||
AdminGetAgentWalletResp {
|
||||
Balance float64 `json:"balance"` // 可用余额
|
||||
FrozenBalance float64 `json:"frozen_balance"` // 冻结余额
|
||||
TotalEarnings float64 `json:"total_earnings"` // 总收益
|
||||
}
|
||||
|
||||
// 修改代理钱包余额请求
|
||||
AdminUpdateAgentWalletBalanceReq {
|
||||
AgentId int64 `json:"agent_id"` // 代理ID
|
||||
Amount float64 `json:"amount"` // 修改金额(正数增加,负数减少)
|
||||
}
|
||||
|
||||
// 修改代理钱包余额响应
|
||||
AdminUpdateAgentWalletBalanceResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
Balance float64 `json:"balance"` // 修改后的余额
|
||||
}
|
||||
|
||||
// 更新系统配置请求
|
||||
AdminUpdateSystemConfigReq {
|
||||
CommissionSafeMode *bool `json:"commission_safe_mode,optional"` // 佣金安全防御模式:true-冻结模式,false-直接结算模式
|
||||
}
|
||||
|
||||
// 更新系统配置响应
|
||||
AdminUpdateSystemConfigResp {
|
||||
Success bool `json:"success"` // 是否成功
|
||||
}
|
||||
|
||||
// 获取系统配置响应
|
||||
AdminGetSystemConfigResp {
|
||||
CommissionSafeMode bool `json:"commission_safe_mode"` // 佣金安全防御模式
|
||||
}
|
||||
|
||||
// 代理钱包流水分页查询请求
|
||||
AdminGetAgentWalletTransactionListReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
@@ -573,7 +514,6 @@ type (
|
||||
CreateTimeStart *string `form:"create_time_start,optional"` // 创建时间开始(可选)
|
||||
CreateTimeEnd *string `form:"create_time_end,optional"` // 创建时间结束(可选)
|
||||
}
|
||||
|
||||
// 代理钱包流水列表项
|
||||
AgentWalletTransactionListItem {
|
||||
Id int64 `json:"id"` // 主键
|
||||
@@ -589,11 +529,10 @@ type (
|
||||
Remark *string `json:"remark"` // 备注说明
|
||||
CreateTime string `json:"create_time"` // 创建时间
|
||||
}
|
||||
|
||||
// 代理钱包流水分页查询响应
|
||||
AdminGetAgentWalletTransactionListResp {
|
||||
Total int64 `json:"total"` // 总数
|
||||
Items []AgentWalletTransactionListItem `json:"items"` // 列表数据
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
|
||||
@@ -363,6 +363,7 @@ type (
|
||||
Remark string `json:"remark"`
|
||||
payeeAccount string `json:"payee_account"`
|
||||
CreateTime string `json:"create_time"`
|
||||
TaxRate float64 `json:"tax_rate"` // 扣税比例,如 0.06 表示 6%
|
||||
}
|
||||
GetWithdrawalReq {
|
||||
Page int64 `form:"page"` // 页码
|
||||
|
||||
@@ -17,6 +17,12 @@ VerifyCode:
|
||||
SignName: "海南海宇大数据"
|
||||
TemplateCode: "SMS_302641455"
|
||||
ValidTime: 300
|
||||
Captcha:
|
||||
AccessKeyID: "LTAI5tKGB3TVJbMHSoZN3yr9"
|
||||
AccessKeySecret: "OCQ30GWp4yENMjmfOAaagksE18bp65"
|
||||
EndpointURL: "captcha.cn-shanghai.aliyuncs.com"
|
||||
SceneID: "wynt39to"
|
||||
EKey: ""
|
||||
Encrypt:
|
||||
SecretKey: "ff83609b2b24fc73196aac3d3dfb874f"
|
||||
WestConfig:
|
||||
|
||||
@@ -19,6 +19,12 @@ VerifyCode:
|
||||
SignName: "海南海宇大数据"
|
||||
TemplateCode: "SMS_302641455"
|
||||
ValidTime: 300
|
||||
Captcha:
|
||||
AccessKeyID: "LTAI5tKGB3TVJbMHSoZN3yr9"
|
||||
AccessKeySecret: "OCQ30GWp4yENMjmfOAaagksE18bp65"
|
||||
EndpointURL: "captcha.cn-shanghai.aliyuncs.com"
|
||||
SceneID: "wynt39to"
|
||||
EKey: ""
|
||||
Encrypt:
|
||||
SecretKey: "ff83609b2b24fc73196aac3d3dfb874f"
|
||||
WestConfig:
|
||||
|
||||
@@ -11,6 +11,7 @@ type Config struct {
|
||||
CacheRedis cache.CacheConf
|
||||
JwtAuth JwtAuth // JWT 鉴权相关配置
|
||||
VerifyCode VerifyCode
|
||||
Captcha CaptchaConfig
|
||||
Encrypt Encrypt
|
||||
Alipay AlipayConfig
|
||||
Wxpay WxpayConfig
|
||||
@@ -42,6 +43,13 @@ type VerifyCode struct {
|
||||
TemplateCode string
|
||||
ValidTime int
|
||||
}
|
||||
type CaptchaConfig struct {
|
||||
AccessKeyID string
|
||||
AccessKeySecret string
|
||||
EndpointURL string
|
||||
SceneID string
|
||||
EKey string
|
||||
}
|
||||
type Encrypt struct {
|
||||
SecretKey string
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"tyass-server/app/main/api/internal/logic/auth"
|
||||
@@ -23,7 +24,10 @@ func SendSmsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
result.ParamValidateErrorResult(r, w, err)
|
||||
return
|
||||
}
|
||||
l := auth.NewSendSmsLogic(r.Context(), svcCtx)
|
||||
|
||||
// 将 User-Agent 添加到上下文中
|
||||
ctx := context.WithValue(r.Context(), "user-agent", r.Header.Get("User-Agent"))
|
||||
l := auth.NewSendSmsLogic(ctx, svcCtx)
|
||||
err := l.SendSms(&req)
|
||||
result.HttpResult(r, w, nil, err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"tyass-server/app/main/api/internal/logic/captcha"
|
||||
"tyass-server/app/main/api/internal/svc"
|
||||
"tyass-server/common/result"
|
||||
)
|
||||
|
||||
func GetEncryptedSceneIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := captcha.NewGetEncryptedSceneIdLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetEncryptedSceneId()
|
||||
result.HttpResult(r, w, resp, err)
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
notification "tyass-server/app/main/api/internal/handler/notification"
|
||||
pay "tyass-server/app/main/api/internal/handler/pay"
|
||||
product "tyass-server/app/main/api/internal/handler/product"
|
||||
captchaHandler "tyass-server/app/main/api/internal/handler/captcha"
|
||||
query "tyass-server/app/main/api/internal/handler/query"
|
||||
user "tyass-server/app/main/api/internal/handler/user"
|
||||
"tyass-server/app/main/api/internal/svc"
|
||||
@@ -914,6 +915,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
rest.WithPrefix("/api/v1"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/captcha/encryptedSceneId",
|
||||
Handler: captchaHandler.GetEncryptedSceneIdHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/v1"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
|
||||
@@ -65,6 +65,11 @@ func (l *AdminGetAgentWithdrawalListLogic) AdminGetAgentWithdrawalList(req *type
|
||||
item.PayeeName = v.PayeeName.String
|
||||
}
|
||||
|
||||
// 从扣税记录中取扣税比例
|
||||
taxModel, taxErr := l.svcCtx.AgentWithdrawalTaxModel.FindOneByWithdrawalId(l.ctx, v.Id)
|
||||
if taxErr == nil {
|
||||
item.TaxRate = taxModel.TaxRate
|
||||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
resp = &types.AdminGetAgentWithdrawalListResp{
|
||||
|
||||
@@ -3,6 +3,7 @@ package admin_agent
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"math"
|
||||
"time"
|
||||
"tyass-server/app/main/model"
|
||||
"tyass-server/common/xerr"
|
||||
@@ -48,7 +49,6 @@ func NewAdminReviewBankCardWithdrawalLogic(ctx context.Context, svcCtx *svc.Serv
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) AdminReviewBankCardWithdrawal(req *types.AdminReviewBankCardWithdrawalReq) (resp *types.AdminReviewBankCardWithdrawalResp, err error) {
|
||||
// 验证操作类型
|
||||
if req.Action != ReviewActionApprove && req.Action != ReviewActionReject {
|
||||
@@ -85,9 +85,18 @@ func (l *AdminReviewBankCardWithdrawalLogic) AdminReviewBankCardWithdrawal(req *
|
||||
return errors.Wrapf(xerr.NewErrMsg("提现类型不正确"), "提现类型验证失败")
|
||||
}
|
||||
|
||||
// 确认时使用的扣税比例:请求中传入则用传入值,否则默认 6%
|
||||
taxRate := 0.06
|
||||
if req.Action == ReviewActionApprove && req.TaxRate != nil {
|
||||
taxRate = *req.TaxRate
|
||||
if taxRate < 0 || taxRate > 1 {
|
||||
return errors.Wrapf(xerr.NewErrMsg("扣税比例必须在 0~100% 之间"), "扣税比例验证失败")
|
||||
}
|
||||
}
|
||||
|
||||
if req.Action == ReviewActionApprove {
|
||||
// 确认提现
|
||||
return l.approveWithdrawal(ctx, session, record)
|
||||
// 确认提现(可带自定义扣税比例)
|
||||
return l.approveWithdrawal(ctx, session, record, taxRate)
|
||||
} else {
|
||||
// 拒绝提现
|
||||
return l.rejectWithdrawal(ctx, session, record, req.Remark)
|
||||
@@ -102,20 +111,53 @@ func (l *AdminReviewBankCardWithdrawalLogic) AdminReviewBankCardWithdrawal(req *
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// 确认提现
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) approveWithdrawal(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal) error {
|
||||
// 确认提现(taxRate 为扣税比例,如 0.06 表示 6%)
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) approveWithdrawal(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal, taxRate float64) error {
|
||||
// 按审核时选择的扣税比例重新计算并更新提现记录与扣税记录
|
||||
taxModel, err := l.applyReviewTaxRate(ctx, session, record, taxRate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 根据提现类型执行不同的操作
|
||||
if record.WithdrawType == WithdrawTypeAlipay {
|
||||
// 支付宝提现:先调用支付宝转账接口
|
||||
return l.approveAlipayWithdrawal(ctx, session, record)
|
||||
// 支付宝提现:按更新后的实际到账金额调用支付宝转账
|
||||
return l.approveAlipayWithdrawal(ctx, session, record, taxModel)
|
||||
} else {
|
||||
// 银行卡提现:直接更新状态为成功(线下转账)
|
||||
return l.approveBankCardWithdrawal(ctx, session, record)
|
||||
return l.approveBankCardWithdrawal(ctx, session, record, taxModel)
|
||||
}
|
||||
}
|
||||
|
||||
// applyReviewTaxRate 按审核时选择的扣税比例更新提现记录与扣税记录
|
||||
// 返回更新后的扣税记录,避免重复查询导致的版本冲突
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) applyReviewTaxRate(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal, taxRate float64) (*model.AgentWithdrawalTax, error) {
|
||||
// 金额保留两位小数,避免浮点误差并与前端/支付宝一致
|
||||
newTaxAmount := math.Round(record.Amount*taxRate*100) / 100
|
||||
newActualAmount := math.Round((record.Amount-newTaxAmount)*100) / 100
|
||||
|
||||
record.TaxAmount = newTaxAmount
|
||||
record.ActualAmount = newActualAmount
|
||||
if _, err := l.svcCtx.AgentWithdrawalModel.Update(ctx, session, record); err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新提现记录扣税金额失败: %v", err)
|
||||
}
|
||||
|
||||
taxModel, err := l.svcCtx.AgentWithdrawalTaxModel.FindOneByWithdrawalId(ctx, record.Id)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询扣税记录失败: %v", err)
|
||||
}
|
||||
taxModel.TaxRate = taxRate
|
||||
taxModel.TaxAmount = newTaxAmount
|
||||
taxModel.ActualAmount = newActualAmount
|
||||
taxModel.TaxableAmount = record.Amount
|
||||
if err := l.svcCtx.AgentWithdrawalTaxModel.UpdateWithVersion(ctx, session, taxModel); err != nil {
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新扣税记录失败: %v", err)
|
||||
}
|
||||
// 返回更新后的 taxModel,version 已经自动加1
|
||||
return taxModel, nil
|
||||
}
|
||||
|
||||
// 确认支付宝提现
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) approveAlipayWithdrawal(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal) error {
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) approveAlipayWithdrawal(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal, taxModel *model.AgentWithdrawalTax) error {
|
||||
// 同步调用支付宝转账
|
||||
transferResp, err := l.svcCtx.AlipayService.AliTransfer(ctx, record.PayeeAccount, record.PayeeName.String, record.ActualAmount, "公司提现", record.WithdrawNo)
|
||||
if err != nil {
|
||||
@@ -126,11 +168,11 @@ func (l *AdminReviewBankCardWithdrawalLogic) approveAlipayWithdrawal(ctx context
|
||||
switch {
|
||||
case transferResp.Status == "SUCCESS":
|
||||
// 立即处理成功状态
|
||||
return l.completeWithdrawalSuccess(ctx, session, record)
|
||||
return l.completeWithdrawalSuccess(ctx, session, record, taxModel)
|
||||
case transferResp.Status == "FAIL" || transferResp.SubCode != "":
|
||||
// 处理明确失败
|
||||
errorMsg := l.mapAlipayError(transferResp.SubCode)
|
||||
return l.completeWithdrawalFailure(ctx, session, record, errorMsg)
|
||||
return l.completeWithdrawalFailure(ctx, session, record, taxModel, errorMsg)
|
||||
case transferResp.Status == "DEALING":
|
||||
// 处理中状态,更新为处理中但不标记为最终状态
|
||||
record.Remark = sql.NullString{String: "支付宝转账处理中", Valid: true}
|
||||
@@ -141,12 +183,12 @@ func (l *AdminReviewBankCardWithdrawalLogic) approveAlipayWithdrawal(ctx context
|
||||
return nil
|
||||
default:
|
||||
// 未知状态按失败处理
|
||||
return l.completeWithdrawalFailure(ctx, session, record, "支付宝返回未知状态")
|
||||
return l.completeWithdrawalFailure(ctx, session, record, taxModel, "支付宝返回未知状态")
|
||||
}
|
||||
}
|
||||
|
||||
// 确认银行卡提现
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) approveBankCardWithdrawal(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal) error {
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) approveBankCardWithdrawal(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal, taxModel *model.AgentWithdrawalTax) error {
|
||||
// 更新提现记录状态为成功
|
||||
record.Status = StatusSuccess
|
||||
record.Remark = sql.NullString{String: "管理员确认提现", Valid: true}
|
||||
@@ -188,11 +230,7 @@ func (l *AdminReviewBankCardWithdrawalLogic) approveBankCardWithdrawal(ctx conte
|
||||
return err
|
||||
}
|
||||
|
||||
// 更新扣税记录状态为成功
|
||||
taxModel, err := l.svcCtx.AgentWithdrawalTaxModel.FindOneByWithdrawalId(ctx, record.Id)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询扣税记录失败: %v", err)
|
||||
}
|
||||
// 更新扣税记录状态为成功(使用传入的 taxModel,避免重复查询导致的版本冲突)
|
||||
if taxModel.TaxStatus == model.TaxStatusPending {
|
||||
taxModel.TaxStatus = model.TaxStatusSuccess // 扣税状态 = 成功
|
||||
taxModel.TaxTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||
@@ -277,7 +315,7 @@ func (l *AdminReviewBankCardWithdrawalLogic) rejectWithdrawal(ctx context.Contex
|
||||
}
|
||||
|
||||
// 完成提现成功(支付宝转账成功后调用)
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalSuccess(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal) error {
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalSuccess(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal, taxModel *model.AgentWithdrawalTax) error {
|
||||
// 更新提现记录状态为成功
|
||||
record.Status = StatusSuccess
|
||||
record.Remark = sql.NullString{String: "支付宝转账成功", Valid: true}
|
||||
@@ -319,11 +357,7 @@ func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalSuccess(ctx conte
|
||||
return err
|
||||
}
|
||||
|
||||
// 更新扣税记录状态为成功
|
||||
taxModel, err := l.svcCtx.AgentWithdrawalTaxModel.FindOneByWithdrawalId(ctx, record.Id)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询扣税记录失败: %v", err)
|
||||
}
|
||||
// 更新扣税记录状态为成功(使用传入的 taxModel,避免重复查询导致的版本冲突)
|
||||
if taxModel.TaxStatus == model.TaxStatusPending {
|
||||
taxModel.TaxStatus = model.TaxStatusSuccess // 扣税状态 = 成功
|
||||
taxModel.TaxTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||
@@ -346,7 +380,7 @@ func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalSuccess(ctx conte
|
||||
}
|
||||
|
||||
// 完成提现失败(支付宝转账失败后调用)
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalFailure(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal, errorMsg string) error {
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalFailure(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal, taxModel *model.AgentWithdrawalTax, errorMsg string) error {
|
||||
// 更新提现记录状态为失败
|
||||
record.Status = StatusFailed
|
||||
record.Remark = sql.NullString{String: errorMsg, Valid: true}
|
||||
@@ -390,11 +424,7 @@ func (l *AdminReviewBankCardWithdrawalLogic) completeWithdrawalFailure(ctx conte
|
||||
return err
|
||||
}
|
||||
|
||||
// 更新扣税记录状态为失败
|
||||
taxModel, err := l.svcCtx.AgentWithdrawalTaxModel.FindOneByWithdrawalId(ctx, record.Id)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询扣税记录失败: %v", err)
|
||||
}
|
||||
// 更新扣税记录状态为失败(使用传入的 taxModel,避免重复查询导致的版本冲突)
|
||||
if taxModel.TaxStatus == model.TaxStatusPending {
|
||||
taxModel.TaxStatus = model.TaxStatusFailed // 扣税状态 = 失败
|
||||
taxModel.TaxTime = sql.NullTime{Time: time.Now(), Valid: true}
|
||||
|
||||
@@ -56,6 +56,11 @@ func (l *GetAgentWithdrawalLogic) GetAgentWithdrawal(req *types.GetWithdrawalReq
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "获取代理提现列表, %v", err)
|
||||
}
|
||||
withdrawal.CreateTime = agentWithdrawalModel.CreateTime.Format("2006-01-02 15:04:05")
|
||||
// 从扣税记录中取扣税比例,供前端展示“扣了几个点”
|
||||
taxModel, taxErr := l.svcCtx.AgentWithdrawalTaxModel.FindOneByWithdrawalId(l.ctx, agentWithdrawalModel.Id)
|
||||
if taxErr == nil {
|
||||
withdrawal.TaxRate = taxModel.TaxRate
|
||||
}
|
||||
list = append(list, withdrawal)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
"tyass-server/app/main/api/internal/svc"
|
||||
"tyass-server/app/main/api/internal/types"
|
||||
"tyass-server/pkg/captcha"
|
||||
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
dysmsapi "github.com/alibabacloud-go/dysmsapi-20170525/v3/client"
|
||||
@@ -35,6 +36,17 @@ func NewSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendSmsLo
|
||||
}
|
||||
|
||||
func (l *SendSmsLogic) SendSms(req *types.SendSmsReq) error {
|
||||
// 图形验证码校验
|
||||
captchaCfg := l.svcCtx.Config.Captcha
|
||||
if err := captcha.VerifyWithContext(l.ctx, captcha.Config{
|
||||
AccessKeyID: captchaCfg.AccessKeyID,
|
||||
AccessKeySecret: captchaCfg.AccessKeySecret,
|
||||
EndpointURL: captchaCfg.EndpointURL,
|
||||
SceneID: captchaCfg.SceneID,
|
||||
}, req.CaptchaVerifyParam); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
secretKey := l.svcCtx.Config.Encrypt.SecretKey
|
||||
encryptedMobile, err := crypto.EncryptMobile(req.Mobile, secretKey)
|
||||
if err != nil {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"tyass-server/app/main/api/internal/svc"
|
||||
"tyass-server/app/main/api/internal/types"
|
||||
"tyass-server/pkg/captcha"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetEncryptedSceneIdLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetEncryptedSceneIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEncryptedSceneIdLogic {
|
||||
return &GetEncryptedSceneIdLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetEncryptedSceneIdLogic) GetEncryptedSceneId() (*types.GetEncryptedSceneIdResp, error) {
|
||||
cfg := l.svcCtx.Config.Captcha
|
||||
encrypted, err := captcha.GenerateEncryptedSceneID(cfg.SceneID, cfg.EKey, 3600)
|
||||
if err != nil {
|
||||
l.Errorf("generate encrypted scene id error: %+v", err)
|
||||
return nil, err
|
||||
}
|
||||
return &types.GetEncryptedSceneIdResp{
|
||||
EncryptedSceneId: encrypted,
|
||||
}, nil
|
||||
}
|
||||
@@ -811,6 +811,7 @@ type AdminReviewBankCardWithdrawalReq struct {
|
||||
WithdrawalId int64 `json:"withdrawal_id"` // 提现记录ID
|
||||
Action int64 `json:"action"` // 操作:1-确认,2-拒绝
|
||||
Remark string `json:"remark"` // 备注(拒绝时必填)
|
||||
TaxRate *float64 `json:"tax_rate,optional"` // 扣税比例,如 0.06 表示 6%,不传则默认 6%
|
||||
}
|
||||
|
||||
type AdminReviewBankCardWithdrawalResp struct {
|
||||
@@ -1300,6 +1301,7 @@ type AgentWithdrawalListItem struct {
|
||||
Amount float64 `json:"amount"` // 金额
|
||||
ActualAmount float64 `json:"actual_amount"` // 实际到账金额(扣税后)
|
||||
TaxAmount float64 `json:"tax_amount"` // 扣税金额
|
||||
TaxRate float64 `json:"tax_rate"` // 扣税比例,如 0.06 表示 6%
|
||||
Status int64 `json:"status"` // 状态
|
||||
PayeeAccount string `json:"payee_account"` // 收款账户
|
||||
Remark string `json:"remark"` // 备注
|
||||
@@ -2053,6 +2055,10 @@ type QueryServiceResp struct {
|
||||
RefreshAfter int64 `json:"refreshAfter"`
|
||||
}
|
||||
|
||||
type GetEncryptedSceneIdResp struct {
|
||||
EncryptedSceneId string `json:"encryptedSceneId"`
|
||||
}
|
||||
|
||||
type QueryShareDetailReq struct {
|
||||
Id string `path:"id"`
|
||||
}
|
||||
@@ -2198,6 +2204,7 @@ type Withdrawal struct {
|
||||
Remark string `json:"remark"`
|
||||
PayeeAccount string `json:"payee_account"`
|
||||
CreateTime string `json:"create_time"`
|
||||
TaxRate float64 `json:"tax_rate"` // 扣税比例,如 0.06 表示 6%
|
||||
}
|
||||
|
||||
type WithdrawalReq struct {
|
||||
@@ -2219,4 +2226,5 @@ type GetAppVersionResp struct {
|
||||
type SendSmsReq struct {
|
||||
Mobile string `json:"mobile" validate:"required,mobile"`
|
||||
ActionType string `json:"actionType" validate:"required,oneof=login register query agentApply realName bindMobile"`
|
||||
CaptchaVerifyParam string `json:"captchaVerifyParam"`
|
||||
}
|
||||
|
||||
9
go.mod
9
go.mod
@@ -6,9 +6,9 @@ toolchain go1.23.4
|
||||
|
||||
require (
|
||||
github.com/Masterminds/squirrel v1.5.4
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.10
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.1.13
|
||||
github.com/alibabacloud-go/dysmsapi-20170525/v3 v3.0.6
|
||||
github.com/alibabacloud-go/tea v1.2.2
|
||||
github.com/alibabacloud-go/tea v1.3.13
|
||||
github.com/alibabacloud-go/tea-utils/v2 v2.0.7
|
||||
github.com/bytedance/sonic v1.13.0
|
||||
github.com/cenkalti/backoff/v4 v4.3.0
|
||||
@@ -37,16 +37,17 @@ require (
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 // indirect
|
||||
github.com/alibabacloud-go/captcha-20230305 v1.1.3 // indirect
|
||||
github.com/alibabacloud-go/debug v1.0.1 // indirect
|
||||
github.com/alibabacloud-go/endpoint-util v1.1.0 // indirect
|
||||
github.com/alibabacloud-go/openapi-util v0.1.0 // indirect
|
||||
github.com/alibabacloud-go/tea-utils v1.3.1 // indirect
|
||||
github.com/alibabacloud-go/tea-xml v1.1.3 // indirect
|
||||
github.com/aliyun/credentials-go v1.3.10 // indirect
|
||||
github.com/aliyun/credentials-go v1.4.5 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.2 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.5.5 // indirect
|
||||
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
|
||||
33
go.sum
33
go.sum
@@ -13,6 +13,8 @@ github.com/alibabacloud-go/alibabacloud-gateway-pop v0.0.6/go.mod h1:4EUIoxs/do2
|
||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.4/go.mod h1:sCavSAvdzOjul4cEqeVtvlSaSScfNsTQ+46HwlTL1hc=
|
||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5 h1:zE8vH9C7JiZLNJJQ5OwjU9mSi4T9ef9u3BURT6LCLC8=
|
||||
github.com/alibabacloud-go/alibabacloud-gateway-spi v0.0.5/go.mod h1:tWnyE9AjF8J8qqLk645oUmVUnFybApTQWklQmi5tY6g=
|
||||
github.com/alibabacloud-go/captcha-20230305 v1.1.3 h1:0Aobw12m3x28aeDMPjwjXsfF8MuLvRjlQ4Hhoy5hFOY=
|
||||
github.com/alibabacloud-go/captcha-20230305 v1.1.3/go.mod h1:ydzBIN2OiM7eeQPpAFyBrv1H5TY1MtUP2rQig44C4UQ=
|
||||
github.com/alibabacloud-go/darabonba-array v0.1.0 h1:vR8s7b1fWAQIjEjWnuF0JiKsCvclSRTfDzZHTYqfufY=
|
||||
github.com/alibabacloud-go/darabonba-array v0.1.0/go.mod h1:BLKxr0brnggqOJPqT09DFJ8g3fsDshapUD3C3aOEFaI=
|
||||
github.com/alibabacloud-go/darabonba-encode-util v0.0.2 h1:1uJGrbsGEVqWcWxrS9MyC2NG0Ax+GpOM5gtupki31XE=
|
||||
@@ -22,6 +24,8 @@ github.com/alibabacloud-go/darabonba-map v0.0.2/go.mod h1:28AJaX8FOE/ym8OUFWga+M
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.2/go.mod h1:5JHVmnHvGzR2wNdgaW1zDLQG8kOC4Uec8ubkMogW7OQ=
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.10 h1:GEYkMApgpKEVDn6z12DcH1EGYpDYRB8JxsazM4Rywak=
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.0.10/go.mod h1:26a14FGhZVELuz2cc2AolvW4RHmIO3/HRwsdHhaIPDE=
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.1.13 h1:Q00FU3H94Ts0ZIHDmY+fYGgB7dV9D/YX6FGsgorQPgw=
|
||||
github.com/alibabacloud-go/darabonba-openapi/v2 v2.1.13/go.mod h1:lxFGfobinVsQ49ntjpgWghXmIF0/Sm4+wvBJ1h5RtaE=
|
||||
github.com/alibabacloud-go/darabonba-signature-util v0.0.7 h1:UzCnKvsjPFzApvODDNEYqBHMFt1w98wC7FOo0InLyxg=
|
||||
github.com/alibabacloud-go/darabonba-signature-util v0.0.7/go.mod h1:oUzCYV2fcCH797xKdL6BDH8ADIHlzrtKVjeRtunBNTQ=
|
||||
github.com/alibabacloud-go/darabonba-string v1.0.2 h1:E714wms5ibdzCqGeYJ9JCFywE5nDyvIXIIQbZVFkkqo=
|
||||
@@ -46,6 +50,8 @@ github.com/alibabacloud-go/tea v1.1.19/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy
|
||||
github.com/alibabacloud-go/tea v1.1.20/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A=
|
||||
github.com/alibabacloud-go/tea v1.2.2 h1:aTsR6Rl3ANWPfqeQugPglfurloyBJY85eFy7Gc1+8oU=
|
||||
github.com/alibabacloud-go/tea v1.2.2/go.mod h1:CF3vOzEMAG+bR4WOql8gc2G9H3EkH3ZLAQdpmpXMgwk=
|
||||
github.com/alibabacloud-go/tea v1.3.13 h1:WhGy6LIXaMbBM6VBYcsDCz6K/TPsT1Ri2hPmmZffZ94=
|
||||
github.com/alibabacloud-go/tea v1.3.13/go.mod h1:A560v/JTQ1n5zklt2BEpurJzZTI8TUT+Psg2drWlxRg=
|
||||
github.com/alibabacloud-go/tea-utils v1.3.1 h1:iWQeRzRheqCMuiF3+XkfybB3kTgUXkXX+JMrqfLeB2I=
|
||||
github.com/alibabacloud-go/tea-utils v1.3.1/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQdSngxrpF8rKUDJjPE=
|
||||
github.com/alibabacloud-go/tea-utils/v2 v2.0.0/go.mod h1:U5MTY10WwlquGPS34DOeomUGBB0gXbLueiq5Trwu0C4=
|
||||
@@ -64,6 +70,8 @@ github.com/aliyun/credentials-go v1.3.1/go.mod h1:8jKYhQuDawt8x2+fusqa1Y6mPxemTs
|
||||
github.com/aliyun/credentials-go v1.3.6/go.mod h1:1LxUuX7L5YrZUWzBrRyk0SwSdH4OmPrib8NVePL3fxM=
|
||||
github.com/aliyun/credentials-go v1.3.10 h1:45Xxrae/evfzQL9V10zL3xX31eqgLWEaIdCoPipOEQA=
|
||||
github.com/aliyun/credentials-go v1.3.10/go.mod h1:Jm6d+xIgwJVLVWT561vy67ZRP4lPTQxMbEYRuT2Ti1U=
|
||||
github.com/aliyun/credentials-go v1.4.5 h1:O76WYKgdy1oQYYiJkERjlA2dxGuvLRrzuO2ScrtGWSk=
|
||||
github.com/aliyun/credentials-go v1.4.5/go.mod h1:Jm6d+xIgwJVLVWT561vy67ZRP4lPTQxMbEYRuT2Ti1U=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
@@ -83,6 +91,8 @@ github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UF
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/clbanning/mxj/v2 v2.5.5 h1:oT81vUeEiQQ/DcHbzSytRngP6Ky9O+L+0Bw0zSJag9E=
|
||||
github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
@@ -326,10 +336,13 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
||||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
||||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
@@ -342,6 +355,9 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -356,10 +372,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
@@ -370,6 +389,9 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -384,20 +406,27 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||
golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
@@ -406,6 +435,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
|
||||
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
|
||||
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
|
||||
@@ -420,6 +451,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
90
pkg/captcha/aliyun.go
Normal file
90
pkg/captcha/aliyun.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"tyass-server/common/xerr"
|
||||
|
||||
captcha20230305 "github.com/alibabacloud-go/captcha-20230305/client"
|
||||
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
|
||||
"github.com/alibabacloud-go/tea/tea"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
AccessKeyID string
|
||||
AccessKeySecret string
|
||||
EndpointURL string
|
||||
SceneID string
|
||||
}
|
||||
|
||||
// Verify 验证图形验证码,支持微信环境跳过验证
|
||||
func Verify(cfg Config, captchaVerifyParam string) error {
|
||||
return VerifyWithContext(context.Background(), cfg, captchaVerifyParam)
|
||||
}
|
||||
|
||||
// VerifyWithContext 带上下文的验证函数
|
||||
func VerifyWithContext(ctx context.Context, cfg Config, captchaVerifyParam string) error {
|
||||
// 开发环境直接通过
|
||||
if os.Getenv("ENV") == "development" {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 检查是否为微信环境
|
||||
if isWechatEnvironment(ctx) {
|
||||
return nil
|
||||
}
|
||||
|
||||
if captchaVerifyParam == "" {
|
||||
return errors.Wrapf(xerr.NewErrMsg("图形验证码校验失败"), "empty captchaVerifyParam")
|
||||
}
|
||||
|
||||
clientCfg := &openapi.Config{
|
||||
AccessKeyId: tea.String(cfg.AccessKeyID),
|
||||
AccessKeySecret: tea.String(cfg.AccessKeySecret),
|
||||
}
|
||||
clientCfg.Endpoint = tea.String(cfg.EndpointURL)
|
||||
client, err := captcha20230305.NewClient(clientCfg)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "captcha client create error: %+v", err)
|
||||
}
|
||||
|
||||
req := &captcha20230305.VerifyIntelligentCaptchaRequest{
|
||||
SceneId: tea.String(cfg.SceneID),
|
||||
CaptchaVerifyParam: tea.String(captchaVerifyParam),
|
||||
}
|
||||
resp, err := client.VerifyIntelligentCaptcha(req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "captcha verify error: %+v", err)
|
||||
}
|
||||
if tea.BoolValue(resp.Body.Result.VerifyResult) {
|
||||
return nil
|
||||
}
|
||||
return errors.Wrapf(xerr.NewErrMsg("图形验证码校验失败"), "verifyResult=false")
|
||||
}
|
||||
|
||||
// isWechatEnvironment 检查是否为微信环境
|
||||
func isWechatEnvironment(ctx context.Context) bool {
|
||||
// 从上下文中获取请求头
|
||||
userAgent := ""
|
||||
if val := ctx.Value("user-agent"); val != nil {
|
||||
if ua, ok := val.(string); ok {
|
||||
userAgent = ua
|
||||
}
|
||||
}
|
||||
if val := ctx.Value("User-Agent"); val != nil {
|
||||
if ua, ok := val.(string); ok {
|
||||
userAgent = ua
|
||||
}
|
||||
}
|
||||
|
||||
// 检查User-Agent是否包含微信标识
|
||||
if strings.Contains(strings.ToLower(userAgent), "micromessenger") {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
28
pkg/captcha/encrypt_scene.go
Normal file
28
pkg/captcha/encrypt_scene.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package captcha
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
lzcrypto "tyass-server/pkg/lzkit/crypto"
|
||||
)
|
||||
|
||||
func GenerateEncryptedSceneID(sceneId, ekey string, expireSeconds int) (string, error) {
|
||||
if expireSeconds <= 0 || expireSeconds > 86400 {
|
||||
expireSeconds = 3600
|
||||
}
|
||||
|
||||
ts := time.Now().Unix()
|
||||
plaintext := fmt.Sprintf("%s&%d&%d", sceneId, ts, expireSeconds)
|
||||
|
||||
keyBytes, err := base64.StdEncoding.DecodeString(ekey)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("decode ekey error: %w", err)
|
||||
}
|
||||
if len(keyBytes) != 32 {
|
||||
return "", fmt.Errorf("invalid ekey length, need 32 bytes after base64 decode, got %d", len(keyBytes))
|
||||
}
|
||||
|
||||
return lzcrypto.AesEncrypt([]byte(plaintext), keyBytes)
|
||||
}
|
||||
Reference in New Issue
Block a user