Compare commits
2 Commits
de42e69593
...
f31c2d7293
| Author | SHA1 | Date | |
|---|---|---|---|
| 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"` // 页码
|
||||
|
||||
@@ -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,11 +111,15 @@ 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 {
|
||||
// 按审核时选择的扣税比例重新计算并更新提现记录与扣税记录
|
||||
if err := l.applyReviewTaxRate(ctx, session, record, taxRate); err != nil {
|
||||
return err
|
||||
}
|
||||
// 根据提现类型执行不同的操作
|
||||
if record.WithdrawType == WithdrawTypeAlipay {
|
||||
// 支付宝提现:先调用支付宝转账接口
|
||||
// 支付宝提现:按更新后的实际到账金额调用支付宝转账
|
||||
return l.approveAlipayWithdrawal(ctx, session, record)
|
||||
} else {
|
||||
// 银行卡提现:直接更新状态为成功(线下转账)
|
||||
@@ -114,6 +127,32 @@ func (l *AdminReviewBankCardWithdrawalLogic) approveWithdrawal(ctx context.Conte
|
||||
}
|
||||
}
|
||||
|
||||
// applyReviewTaxRate 按审核时选择的扣税比例更新提现记录与扣税记录
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) applyReviewTaxRate(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal, taxRate float64) 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 errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新提现记录扣税金额失败: %v", err)
|
||||
}
|
||||
|
||||
taxModel, err := l.svcCtx.AgentWithdrawalTaxModel.FindOneByWithdrawalId(ctx, record.Id)
|
||||
if err != nil {
|
||||
return 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 errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新扣税记录失败: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 确认支付宝提现
|
||||
func (l *AdminReviewBankCardWithdrawalLogic) approveAlipayWithdrawal(ctx context.Context, session sqlx.Session, record *model.AgentWithdrawal) error {
|
||||
// 同步调用支付宝转账
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"` // 备注
|
||||
@@ -2198,6 +2200,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 {
|
||||
|
||||
Reference in New Issue
Block a user