73 lines
2.9 KiB
Go
73 lines
2.9 KiB
Go
package financewithdrawal
|
|
|
|
import "hyapp-admin-server/internal/model"
|
|
|
|
type withdrawalApplicationDTO struct {
|
|
ID uint `json:"id"`
|
|
AppCode string `json:"appCode"`
|
|
AppName string `json:"appName"`
|
|
UserID string `json:"userId"`
|
|
SalaryAssetType string `json:"salaryAssetType"`
|
|
WithdrawAmount string `json:"withdrawAmount"`
|
|
WithdrawAmountMinor int64 `json:"withdrawAmountMinor"`
|
|
PointGrossAmount int64 `json:"pointGrossAmount,omitempty"`
|
|
PointFeeAmount int64 `json:"pointFeeAmount,omitempty"`
|
|
PointNetAmount int64 `json:"pointNetAmount,omitempty"`
|
|
PointsPerUSD int64 `json:"pointsPerUsd,omitempty"`
|
|
PointFeeBPS int32 `json:"pointFeeBps,omitempty"`
|
|
WithdrawMethod string `json:"withdrawMethod"`
|
|
WithdrawAddress string `json:"withdrawAddress"`
|
|
FreezeTransactionID string `json:"freezeTransactionId"`
|
|
AuditTransactionID string `json:"auditTransactionId"`
|
|
Status string `json:"status"`
|
|
ApproverUserID *uint `json:"approverUserId"`
|
|
ApproverName string `json:"approverName"`
|
|
AuditRemark string `json:"auditRemark"`
|
|
AuditImageURL string `json:"auditImageUrl"`
|
|
ApprovedAtMS *int64 `json:"approvedAtMs"`
|
|
CreatedAtMS int64 `json:"createdAtMs"`
|
|
UpdatedAtMS int64 `json:"updatedAtMs"`
|
|
}
|
|
|
|
func withdrawalApplicationDTOFromModel(item model.UserWithdrawalApplication) withdrawalApplicationDTO {
|
|
dto := withdrawalApplicationDTO{
|
|
ID: item.ID,
|
|
AppCode: item.AppCode,
|
|
AppName: item.AppCode,
|
|
UserID: item.UserID,
|
|
SalaryAssetType: item.SalaryAssetType,
|
|
WithdrawAmount: item.WithdrawAmount,
|
|
WithdrawAmountMinor: item.WithdrawAmountMinor,
|
|
WithdrawMethod: item.WithdrawMethod,
|
|
WithdrawAddress: item.WithdrawAddress,
|
|
FreezeTransactionID: item.FreezeTransactionID,
|
|
AuditTransactionID: item.AuditTransactionID,
|
|
Status: item.Status,
|
|
ApproverUserID: item.ApproverUserID,
|
|
ApproverName: item.ApproverName,
|
|
AuditRemark: item.AuditRemark,
|
|
AuditImageURL: item.AuditImageURL,
|
|
ApprovedAtMS: item.ApprovedAtMS,
|
|
CreatedAtMS: item.CreatedAtMS,
|
|
UpdatedAtMS: item.UpdatedAtMS,
|
|
}
|
|
if isPointWithdrawalAssetType(item.SalaryAssetType) {
|
|
grossPoints := item.WithdrawAmountMinor
|
|
feePoints := grossPoints * int64(pointWithdrawalDefaultFeeBPS) / 10000
|
|
dto.PointGrossAmount = grossPoints
|
|
dto.PointFeeAmount = feePoints
|
|
dto.PointNetAmount = grossPoints - feePoints
|
|
dto.PointsPerUSD = pointWithdrawalDefaultPointsPerUSD
|
|
dto.PointFeeBPS = pointWithdrawalDefaultFeeBPS
|
|
}
|
|
return dto
|
|
}
|
|
|
|
func withdrawalApplicationDTOsFromModel(items []model.UserWithdrawalApplication) []withdrawalApplicationDTO {
|
|
out := make([]withdrawalApplicationDTO, 0, len(items))
|
|
for _, item := range items {
|
|
out = append(out, withdrawalApplicationDTOFromModel(item))
|
|
}
|
|
return out
|
|
}
|