@@ -332,12 +332,32 @@ func WithdrawApply(c *gin.Context) { | |||
func GetWithdrawCondition(c *gin.Context) { | |||
user := svc.GetUser(c) | |||
settingDb := implement.NewFinWithdrawSettingDb(db.Db) | |||
setting, err := settingDb.FinWithdrawSettingGetOne() | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err) | |||
return | |||
} | |||
//1. 判断是否为第一次提现 | |||
isFirst := false | |||
has, err := db.Db.Where("uid = ?", user.Id). | |||
Get(model.FinWithdrawApply{}) | |||
if !has { //第一次提现 | |||
isFirst = true | |||
} | |||
resp := svc.GetWithdrawCondition(user, setting, isFirst) | |||
alipayUserInfoDb := implement.NewAlipayUserInfoDb(db.Db) | |||
alipayInfo, err := alipayUserInfoDb.GetAlipayUserInfo(user.Id) | |||
if err != nil { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
if alipayInfo != nil { | |||
resp.IsBindAlipay = true | |||
} | |||
userInfoDb := implement.NewWxUserInfoDb(db.Db) | |||
wxUserInfo, err := userInfoDb.GetWxUserInfo(user.Id) | |||
@@ -345,33 +365,10 @@ func GetWithdrawCondition(c *gin.Context) { | |||
e.OutErr(c, e.ERR_DB_ORM, err.Error()) | |||
return | |||
} | |||
resp := md.GetWithdrawConditionResp{ | |||
IsRealName: func(isRealName int) bool { | |||
switch isRealName { | |||
case 0: | |||
return false | |||
case 1: | |||
return true | |||
default: | |||
return false | |||
} | |||
}(user.IsRealName), | |||
IsBindAlipay: func(alipayInfo *model.AlipayUserInfo) bool { | |||
if alipayInfo == nil { | |||
return false | |||
} else { | |||
return true | |||
} | |||
}(alipayInfo), | |||
IsBindWx: func(wxUserInfo *model.WxUserInfo) bool { | |||
if wxUserInfo == nil { | |||
return false | |||
} else { | |||
return true | |||
} | |||
}(wxUserInfo), | |||
if wxUserInfo != nil { | |||
resp.IsBindWx = true | |||
} | |||
e.OutSuc(c, resp, nil) | |||
} | |||
@@ -32,9 +32,12 @@ type WithdrawApplyReq struct { | |||
} | |||
type GetWithdrawConditionResp struct { | |||
IsRealName bool `json:"is_real_name"` // 是否实名 | |||
IsBindAlipay bool `json:"is_bind_alipay"` // 是否绑定阿里账户 | |||
IsBindWx bool `json:"is_bind_wx"` // 是否绑定微信账户 | |||
IsNeedRealName bool `json:"is_need_real_name"` // 是否需要实名 | |||
IsRealName bool `json:"is_real_name"` // 是否实名 | |||
IsBindAlipay bool `json:"is_bind_alipay"` // 是否绑定阿里账户 | |||
IsBindWx bool `json:"is_bind_wx"` // 是否绑定微信账户 | |||
IsCanWithdraw bool `json:"is_can_withdraw"` // 是否能提现 | |||
NotWithdrawReason string `json:"not_withdraw_reason"` // 不能提现原因 | |||
} | |||
type BindAlipayAccountReq struct { | |||
@@ -3,9 +3,11 @@ package svc | |||
import ( | |||
"applet/app/db" | |||
"applet/app/e" | |||
md2 "applet/app/md" | |||
"applet/app/utils" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/implement" | |||
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" | |||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum" | |||
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" | |||
"errors" | |||
"github.com/gin-gonic/gin" | |||
@@ -30,10 +32,8 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st | |||
//2、判断是否为第一次提现 | |||
var isCompleteFirstWithdraw bool | |||
has, err := db.Db.Where("uid = ? and ", user.Id). | |||
And("uid =?", user.Id). | |||
Get(model.FinWithdrawApply{}) | |||
if has { //第一次提现 | |||
has, err := db.Db.Where("uid =?", user.Id).Get(model.FinWithdrawApply{}) | |||
if !has { //第一次提现 | |||
isFirst = true | |||
var firstWithdrawSet md.FirstWithdrawSet | |||
utils.Unserialize([]byte(withdrawSetting.FrequencySet), &firstWithdrawSet) | |||
@@ -171,3 +171,84 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st | |||
return | |||
} | |||
func GetWithdrawCondition(user *model.User, setting *model.FinWithdrawSetting, isFirst bool) md2.GetWithdrawConditionResp { | |||
resp := md2.GetWithdrawConditionResp{ | |||
IsCanWithdraw: true, | |||
IsBindAlipay: false, | |||
IsBindWx: false, | |||
} | |||
// 1.判断是否需要实名 | |||
switch setting.IsRealName { | |||
case 0: | |||
resp.IsNeedRealName = false | |||
case 1: | |||
resp.IsNeedRealName = true | |||
default: | |||
resp.IsNeedRealName = true | |||
} | |||
// 2.判断是否实名 | |||
switch user.IsRealName { | |||
case 0: | |||
resp.IsRealName = false | |||
if resp.IsNeedRealName { | |||
// 2.1 需要实名但未实名 | |||
resp.IsCanWithdraw = false | |||
resp.NotWithdrawReason = enum.FinWithdrawApplyWithdrawConditionDissatisfyKind. | |||
String(enum.FinWithdrawApplyWithdrawConditionDissatisfyKindNotRealName) | |||
} | |||
case 1: | |||
resp.IsRealName = true | |||
default: | |||
resp.IsRealName = false | |||
} | |||
// 3. 验证会员等级 | |||
if setting.VipLevelLimit > 0 && setting.VipLevelLimit > user.Level { | |||
resp.IsCanWithdraw = false | |||
resp.NotWithdrawReason = enum.FinWithdrawApplyWithdrawConditionDissatisfyKind. | |||
String(enum.FinWithdrawApplyWithdrawConditionDissatisfyKindNotEnoughLevel) | |||
} | |||
//4、验证时段 | |||
now := time.Now() | |||
if setting.WithdrawTimeInterval != "" { | |||
withdrawTimeInterval := strings.Split(setting.WithdrawTimeInterval, "-") | |||
// 定义要比较的时间格式 | |||
layout := "15:04" | |||
// 解析给定的时间字符串 | |||
start, _ := time.Parse(layout, withdrawTimeInterval[0]) | |||
end, _ := time.Parse(layout, withdrawTimeInterval[1]) | |||
// 设置为今天的日期 | |||
start = time.Date(now.Year(), now.Month(), now.Day(), start.Hour(), start.Minute(), 0, 0, now.Location()) | |||
end = time.Date(now.Year(), now.Month(), now.Day(), end.Hour(), end.Minute(), 0, 0, now.Location()) | |||
// 如果结束时间小于开始时间,说明跨天了 | |||
if end.Before(start) { | |||
if !(now.After(start) || now.Before(end)) { | |||
resp.IsCanWithdraw = false | |||
resp.NotWithdrawReason = enum.FinWithdrawApplyWithdrawConditionDissatisfyKind. | |||
String(enum.FinWithdrawApplyWithdrawConditionDissatisfyKindNotInTime) | |||
} | |||
} else { // 否则,在同一天内比较 | |||
if !(now.After(start) && now.Before(end)) { | |||
resp.IsCanWithdraw = false | |||
resp.NotWithdrawReason = enum.FinWithdrawApplyWithdrawConditionDissatisfyKind. | |||
String(enum.FinWithdrawApplyWithdrawConditionDissatisfyKindNotInTime) | |||
} | |||
} | |||
} | |||
// 5. 首次提现判断 | |||
if isFirst { | |||
var firstWithdrawSet md.FirstWithdrawSet | |||
utils.Unserialize([]byte(setting.FirstWithdrawSet), &firstWithdrawSet) | |||
if firstWithdrawSet.IsNeedRealName == 0 { | |||
resp.IsNeedRealName = false | |||
} | |||
} | |||
return resp | |||
} |
@@ -2972,68 +2972,6 @@ const docTemplate = `{ | |||
} | |||
} | |||
}, | |||
"code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd": { | |||
"type": "object", | |||
"properties": { | |||
"amount": { | |||
"type": "string" | |||
}, | |||
"create_time": { | |||
"type": "string" | |||
}, | |||
"id": { | |||
"type": "integer" | |||
}, | |||
"im_data": { | |||
"type": "string" | |||
}, | |||
"im_uid": { | |||
"type": "integer" | |||
}, | |||
"ord_no": { | |||
"type": "string" | |||
}, | |||
"received_im_user_ids": { | |||
"type": "string" | |||
}, | |||
"received_times": { | |||
"type": "string" | |||
}, | |||
"received_user_amount": { | |||
"type": "string" | |||
}, | |||
"received_user_ids": { | |||
"type": "string" | |||
}, | |||
"red_packet_balance_amount": { | |||
"type": "string" | |||
}, | |||
"red_packet_balance_nums": { | |||
"type": "integer" | |||
}, | |||
"red_packet_nums": { | |||
"type": "integer" | |||
}, | |||
"red_packet_type": { | |||
"type": "integer" | |||
}, | |||
"state": { | |||
"type": "integer" | |||
}, | |||
"uid": { | |||
"type": "integer" | |||
}, | |||
"update_time": { | |||
"type": "string" | |||
}, | |||
"wait_draw_im_user_ids": { | |||
"type": "string" | |||
}, | |||
"wait_draw_user_ids": { | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
"comm.AccessRecordsReq": { | |||
"type": "object", | |||
"properties": { | |||
@@ -3846,9 +3784,21 @@ const docTemplate = `{ | |||
"description": "是否绑定微信账户", | |||
"type": "boolean" | |||
}, | |||
"is_can_withdraw": { | |||
"description": "是否能提现", | |||
"type": "boolean" | |||
}, | |||
"is_need_real_name": { | |||
"description": "是否需要实名", | |||
"type": "boolean" | |||
}, | |||
"is_real_name": { | |||
"description": "是否实名", | |||
"type": "boolean" | |||
}, | |||
"not_withdraw_reason": { | |||
"description": "不能提现原因", | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
@@ -4318,6 +4268,10 @@ const docTemplate = `{ | |||
"auth_state": { | |||
"type": "string", | |||
"example": "0未申请 1申请通过 3申请失败" | |||
}, | |||
"is_need_get_energy": { | |||
"type": "string", | |||
"example": "0不需要获取能量 1弹窗提示 前往蛋蛋乐园获取能量" | |||
} | |||
} | |||
}, | |||
@@ -4360,7 +4314,7 @@ const docTemplate = `{ | |||
"description": "红包详情信息", | |||
"allOf": [ | |||
{ | |||
"$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd" | |||
"$ref": "#/definitions/model.ImSendRedPackageOrd" | |||
} | |||
] | |||
}, | |||
@@ -4985,6 +4939,68 @@ const docTemplate = `{ | |||
} | |||
} | |||
}, | |||
"model.ImSendRedPackageOrd": { | |||
"type": "object", | |||
"properties": { | |||
"amount": { | |||
"type": "string" | |||
}, | |||
"create_time": { | |||
"type": "string" | |||
}, | |||
"id": { | |||
"type": "integer" | |||
}, | |||
"im_data": { | |||
"type": "string" | |||
}, | |||
"im_uid": { | |||
"type": "integer" | |||
}, | |||
"ord_no": { | |||
"type": "string" | |||
}, | |||
"received_im_user_ids": { | |||
"type": "string" | |||
}, | |||
"received_times": { | |||
"type": "string" | |||
}, | |||
"received_user_amount": { | |||
"type": "string" | |||
}, | |||
"received_user_ids": { | |||
"type": "string" | |||
}, | |||
"red_packet_balance_amount": { | |||
"type": "string" | |||
}, | |||
"red_packet_balance_nums": { | |||
"type": "integer" | |||
}, | |||
"red_packet_nums": { | |||
"type": "integer" | |||
}, | |||
"red_packet_type": { | |||
"type": "integer" | |||
}, | |||
"state": { | |||
"type": "integer" | |||
}, | |||
"uid": { | |||
"type": "integer" | |||
}, | |||
"update_time": { | |||
"type": "string" | |||
}, | |||
"wait_draw_im_user_ids": { | |||
"type": "string" | |||
}, | |||
"wait_draw_user_ids": { | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
"pb.SendRedPacketResp": { | |||
"type": "object", | |||
"properties": { | |||
@@ -2966,68 +2966,6 @@ | |||
} | |||
} | |||
}, | |||
"code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd": { | |||
"type": "object", | |||
"properties": { | |||
"amount": { | |||
"type": "string" | |||
}, | |||
"create_time": { | |||
"type": "string" | |||
}, | |||
"id": { | |||
"type": "integer" | |||
}, | |||
"im_data": { | |||
"type": "string" | |||
}, | |||
"im_uid": { | |||
"type": "integer" | |||
}, | |||
"ord_no": { | |||
"type": "string" | |||
}, | |||
"received_im_user_ids": { | |||
"type": "string" | |||
}, | |||
"received_times": { | |||
"type": "string" | |||
}, | |||
"received_user_amount": { | |||
"type": "string" | |||
}, | |||
"received_user_ids": { | |||
"type": "string" | |||
}, | |||
"red_packet_balance_amount": { | |||
"type": "string" | |||
}, | |||
"red_packet_balance_nums": { | |||
"type": "integer" | |||
}, | |||
"red_packet_nums": { | |||
"type": "integer" | |||
}, | |||
"red_packet_type": { | |||
"type": "integer" | |||
}, | |||
"state": { | |||
"type": "integer" | |||
}, | |||
"uid": { | |||
"type": "integer" | |||
}, | |||
"update_time": { | |||
"type": "string" | |||
}, | |||
"wait_draw_im_user_ids": { | |||
"type": "string" | |||
}, | |||
"wait_draw_user_ids": { | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
"comm.AccessRecordsReq": { | |||
"type": "object", | |||
"properties": { | |||
@@ -3840,9 +3778,21 @@ | |||
"description": "是否绑定微信账户", | |||
"type": "boolean" | |||
}, | |||
"is_can_withdraw": { | |||
"description": "是否能提现", | |||
"type": "boolean" | |||
}, | |||
"is_need_real_name": { | |||
"description": "是否需要实名", | |||
"type": "boolean" | |||
}, | |||
"is_real_name": { | |||
"description": "是否实名", | |||
"type": "boolean" | |||
}, | |||
"not_withdraw_reason": { | |||
"description": "不能提现原因", | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
@@ -4312,6 +4262,10 @@ | |||
"auth_state": { | |||
"type": "string", | |||
"example": "0未申请 1申请通过 3申请失败" | |||
}, | |||
"is_need_get_energy": { | |||
"type": "string", | |||
"example": "0不需要获取能量 1弹窗提示 前往蛋蛋乐园获取能量" | |||
} | |||
} | |||
}, | |||
@@ -4354,7 +4308,7 @@ | |||
"description": "红包详情信息", | |||
"allOf": [ | |||
{ | |||
"$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd" | |||
"$ref": "#/definitions/model.ImSendRedPackageOrd" | |||
} | |||
] | |||
}, | |||
@@ -4979,6 +4933,68 @@ | |||
} | |||
} | |||
}, | |||
"model.ImSendRedPackageOrd": { | |||
"type": "object", | |||
"properties": { | |||
"amount": { | |||
"type": "string" | |||
}, | |||
"create_time": { | |||
"type": "string" | |||
}, | |||
"id": { | |||
"type": "integer" | |||
}, | |||
"im_data": { | |||
"type": "string" | |||
}, | |||
"im_uid": { | |||
"type": "integer" | |||
}, | |||
"ord_no": { | |||
"type": "string" | |||
}, | |||
"received_im_user_ids": { | |||
"type": "string" | |||
}, | |||
"received_times": { | |||
"type": "string" | |||
}, | |||
"received_user_amount": { | |||
"type": "string" | |||
}, | |||
"received_user_ids": { | |||
"type": "string" | |||
}, | |||
"red_packet_balance_amount": { | |||
"type": "string" | |||
}, | |||
"red_packet_balance_nums": { | |||
"type": "integer" | |||
}, | |||
"red_packet_nums": { | |||
"type": "integer" | |||
}, | |||
"red_packet_type": { | |||
"type": "integer" | |||
}, | |||
"state": { | |||
"type": "integer" | |||
}, | |||
"uid": { | |||
"type": "integer" | |||
}, | |||
"update_time": { | |||
"type": "string" | |||
}, | |||
"wait_draw_im_user_ids": { | |||
"type": "string" | |||
}, | |||
"wait_draw_user_ids": { | |||
"type": "string" | |||
} | |||
} | |||
}, | |||
"pb.SendRedPacketResp": { | |||
"type": "object", | |||
"properties": { | |||
@@ -12,47 +12,6 @@ definitions: | |||
description: 总数据量 | |||
type: integer | |||
type: object | |||
code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd: | |||
properties: | |||
amount: | |||
type: string | |||
create_time: | |||
type: string | |||
id: | |||
type: integer | |||
im_data: | |||
type: string | |||
im_uid: | |||
type: integer | |||
ord_no: | |||
type: string | |||
received_im_user_ids: | |||
type: string | |||
received_times: | |||
type: string | |||
received_user_amount: | |||
type: string | |||
received_user_ids: | |||
type: string | |||
red_packet_balance_amount: | |||
type: string | |||
red_packet_balance_nums: | |||
type: integer | |||
red_packet_nums: | |||
type: integer | |||
red_packet_type: | |||
type: integer | |||
state: | |||
type: integer | |||
uid: | |||
type: integer | |||
update_time: | |||
type: string | |||
wait_draw_im_user_ids: | |||
type: string | |||
wait_draw_user_ids: | |||
type: string | |||
type: object | |||
comm.AccessRecordsReq: | |||
properties: | |||
index: | |||
@@ -616,9 +575,18 @@ definitions: | |||
is_bind_wx: | |||
description: 是否绑定微信账户 | |||
type: boolean | |||
is_can_withdraw: | |||
description: 是否能提现 | |||
type: boolean | |||
is_need_real_name: | |||
description: 是否需要实名 | |||
type: boolean | |||
is_real_name: | |||
description: 是否实名 | |||
type: boolean | |||
not_withdraw_reason: | |||
description: 不能提现原因 | |||
type: string | |||
type: object | |||
md.GrabRedPackageReq: | |||
properties: | |||
@@ -945,6 +913,9 @@ definitions: | |||
auth_state: | |||
example: 0未申请 1申请通过 3申请失败 | |||
type: string | |||
is_need_get_energy: | |||
example: 0不需要获取能量 1弹窗提示 前往蛋蛋乐园获取能量 | |||
type: string | |||
type: object | |||
md.RealNameAuthResp: | |||
properties: | |||
@@ -972,7 +943,7 @@ definitions: | |||
properties: | |||
detail: | |||
allOf: | |||
- $ref: '#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd' | |||
- $ref: '#/definitions/model.ImSendRedPackageOrd' | |||
description: 红包详情信息 | |||
list: | |||
description: 领取红包用户列表 | |||
@@ -1402,6 +1373,47 @@ definitions: | |||
description: 余额 | |||
type: string | |||
type: object | |||
model.ImSendRedPackageOrd: | |||
properties: | |||
amount: | |||
type: string | |||
create_time: | |||
type: string | |||
id: | |||
type: integer | |||
im_data: | |||
type: string | |||
im_uid: | |||
type: integer | |||
ord_no: | |||
type: string | |||
received_im_user_ids: | |||
type: string | |||
received_times: | |||
type: string | |||
received_user_amount: | |||
type: string | |||
received_user_ids: | |||
type: string | |||
red_packet_balance_amount: | |||
type: string | |||
red_packet_balance_nums: | |||
type: integer | |||
red_packet_nums: | |||
type: integer | |||
red_packet_type: | |||
type: integer | |||
state: | |||
type: integer | |||
uid: | |||
type: integer | |||
update_time: | |||
type: string | |||
wait_draw_im_user_ids: | |||
type: string | |||
wait_draw_user_ids: | |||
type: string | |||
type: object | |||
pb.SendRedPacketResp: | |||
properties: | |||
seq: | |||