拆分提现 Repository 文件职责
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package withdrawal
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 生成提现单号
|
||||
func generateWithdrawNo() (string, error) {
|
||||
buf := make([]byte, 8)
|
||||
if _, err := rand.Read(buf); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("WD%d%s", time.Now().Unix(), hex.EncodeToString(buf)[:8]), nil
|
||||
}
|
||||
|
||||
// 账号脱敏
|
||||
|
||||
// 账号脱敏
|
||||
func maskAccountNo(accountNo, accountType string) string {
|
||||
length := len(accountNo)
|
||||
if length <= 4 {
|
||||
return accountNo
|
||||
}
|
||||
|
||||
switch accountType {
|
||||
case "alipay", "wechat":
|
||||
if length == 11 {
|
||||
return accountNo[:3] + "****" + accountNo[7:]
|
||||
}
|
||||
return accountNo[:2] + "****" + accountNo[length-2:]
|
||||
case "bank":
|
||||
if length > 8 {
|
||||
return accountNo[:4] + "****" + accountNo[length-4:]
|
||||
}
|
||||
return accountNo[:2] + "****" + accountNo[length-2:]
|
||||
}
|
||||
return accountNo
|
||||
}
|
||||
|
||||
// 简化的解密函数(实际应该调用 paymentaccount 模块的解密)
|
||||
|
||||
// 简化的解密函数(实际应该调用 paymentaccount 模块的解密)
|
||||
func (r *Repository) decryptAccountNo(encrypted string) (string, error) {
|
||||
// 这里应该调用 paymentaccount 包的解密函数
|
||||
// 为了简化,直接返回(实际使用时需要正确实现)
|
||||
return encrypted, nil
|
||||
}
|
||||
Reference in New Issue
Block a user