Browse Source

update

master
dengbiao 5 days ago
parent
commit
f56e05ba67
3 changed files with 22 additions and 16 deletions
  1. +2
    -2
      app/hdl/hdl_wallet.go
  2. +1
    -1
      app/md/md.wallet.go
  3. +19
    -13
      app/svc/svc_withdraw_apply.go

+ 2
- 2
app/hdl/hdl_wallet.go View File

@@ -163,7 +163,7 @@ func WithdrawApply(c *gin.Context) {
var userId, openId string
//sysCfgDb := implement.NewSysCfgDb(db.Db, cache.GetPool().Get())
//sysCfgMap := sysCfgDb.SysCfgFindWithDb(enum.AlipayAppId, enum.WxAppId)
if req.Kind == int(enum.FinWithdrawApplyWithdrawKindForAli) {
if req.Kind == enum.FinWithdrawApplyWithdrawKindForAli.String() {
alipayUserInfoDb := implement.NewAlipayUserInfoDb(db.Db)
aliInfo, err := alipayUserInfoDb.GetAlipayUserInfo(user.Id)
if err != nil {
@@ -177,7 +177,7 @@ func WithdrawApply(c *gin.Context) {
//appId = sysCfgMap[enum.AlipayAppId]
userId = aliInfo.UserId
openId = aliInfo.OpenId
} else if req.Kind == int(enum.FinWithdrawApplyWithdrawKindForWx) {
} else if req.Kind == enum.FinWithdrawApplyWithdrawKindForWx.String() {
wxUserInfoDb := implement.NewWxUserInfoDb(db.Db)
wxInfo, err := wxUserInfoDb.GetWxUserInfo(user.Id)
if err != nil {


+ 1
- 1
app/md/md.wallet.go View File

@@ -28,7 +28,7 @@ type WithdrawGetAmountResp struct {

type WithdrawApplyReq struct {
Amount string `json:"amount"` // 金额
Kind int `json:"kind"` // 提现方式(1:支付宝 2:微信)
Kind string `json:"kind"` // 提现方式(alipay:支付宝 wx:微信)
}

type GetWithdrawConditionResp struct {


+ 19
- 13
app/svc/svc_withdraw_apply.go View File

@@ -28,13 +28,27 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st
return
}

//2、判断是否为第一次提现
var isCompleteFirstWithdraw bool
has, err := db.Db.Where("uid = ? and ", user.Id).
And("uid =?", user.Id).
Get(model.FinWithdrawApply{})
if has { //第一次提现
isFirst = true
var firstWithdrawSet md.FirstWithdrawSet
utils.Unserialize([]byte(withdrawSetting.FrequencySet), &firstWithdrawSet)
if firstWithdrawSet.IsNeedRealName == 0 && firstWithdrawSet.FirstWithdrawAmountLimit >= amount {
isCompleteFirstWithdraw = true
}
}

//2、判断“是否实名”
if withdrawSetting.IsRealName == 1 && user.IsRealName != 1 {
if isCompleteFirstWithdraw && withdrawSetting.IsRealName == 1 && user.IsRealName != 1 {
return errors.New("非实名用户不可提现"), realAmount, fee, isAuto, isFirst
}

//3、判断“提现金额”
if utils.StrToFloat64(withdrawSetting.WithdrawAmountLimit) > 0 {
if isCompleteFirstWithdraw && utils.StrToFloat64(withdrawSetting.WithdrawAmountLimit) > 0 {
withdrawAmountLimitValue, _ := decimal.NewFromString(withdrawSetting.WithdrawAmountLimit)
if amountValue.GreaterThan(withdrawAmountLimitValue) {
return errors.New("非可提现金额"), realAmount, fee, isAuto, isFirst
@@ -42,7 +56,7 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st
}

//4、判断“提现倍数”
if utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit) > 0 {
if isCompleteFirstWithdraw && utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit) > 0 {
result := utils.StrToFloat64(amount) / utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit)
// 检查结果是否非常接近一个整数
roundedResult := math.Round(result)
@@ -52,12 +66,12 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st
}

//5、验证会员等级
if withdrawSetting.VipLevelLimit > 0 && withdrawSetting.VipLevelLimit > user.Level {
if isCompleteFirstWithdraw && withdrawSetting.VipLevelLimit > 0 && withdrawSetting.VipLevelLimit > user.Level {
return errors.New("非可提现会员等级"), realAmount, fee, isAuto, isFirst
}

//6、 验证小数点
if withdrawSetting.IsSupportDecimalPoint == 0 && strings.Contains(amount, ".") {
if isCompleteFirstWithdraw && withdrawSetting.IsSupportDecimalPoint == 0 && strings.Contains(amount, ".") {
return errors.New("不支持的提现金额"), realAmount, fee, isAuto, isFirst
}

@@ -151,14 +165,6 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st
}
}

//11、判断是否为第一次提现
has, err := db.Db.Where("uid = ? and ", user.Id).
And("uid =?", user.Id).
Get(model.FinWithdrawApply{})
if has {
isFirst = true
}

if utils.StrToFloat64(realAmount) <= 0 {
return errors.New("当前提现金额有误"), realAmount, fee, isAuto, isFirst
}


Loading…
Cancel
Save