|
|
@@ -1,6 +1,7 @@ |
|
|
|
package svc |
|
|
|
|
|
|
|
import ( |
|
|
|
"applet/app/cfg" |
|
|
|
"applet/app/db" |
|
|
|
"applet/app/e" |
|
|
|
"applet/app/lib/alipay" |
|
|
@@ -9,6 +10,8 @@ import ( |
|
|
|
"applet/app/utils/cache" |
|
|
|
"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" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy" |
|
|
|
"encoding/json" |
|
|
|
"fmt" |
|
|
|
"github.com/gin-gonic/gin" |
|
|
@@ -17,12 +20,20 @@ import ( |
|
|
|
|
|
|
|
func GetRealNameAuthBase(c *gin.Context) { |
|
|
|
var res = &md.RealNameAuthBasicData{ |
|
|
|
AuthState: "0", |
|
|
|
AuthState: "0", |
|
|
|
IsNeedGetEnergy: "1", |
|
|
|
} |
|
|
|
|
|
|
|
res.AuthState = "0" |
|
|
|
//判断审核状态 |
|
|
|
eg := db.Db |
|
|
|
user := GetUser(c) |
|
|
|
egg_system_rules.Init(cfg.RedisAddr) |
|
|
|
amount := GetSysCfgStr("user_real_name_money") |
|
|
|
_, can := egg_energy.CheckActivityCoinToAlipayRealName(db.Db, user.Id, amount) |
|
|
|
if can { |
|
|
|
res.IsNeedGetEnergy = "0" |
|
|
|
} |
|
|
|
NewUserRealNameAuthDb := implement.NewUserRealNameAuthDb(eg) |
|
|
|
list, _ := NewUserRealNameAuthDb.GetRealNameAuthByUid(utils.Int64ToStr(user.Id)) |
|
|
|
if list != nil { |
|
|
@@ -40,6 +51,12 @@ func GetRealNameAuthBase(c *gin.Context) { |
|
|
|
if list.IsPay == 0 { |
|
|
|
res.AuthState = "0" |
|
|
|
} |
|
|
|
if list.IsPay == 1 { |
|
|
|
res.IsNeedGetEnergy = "0" |
|
|
|
} |
|
|
|
} |
|
|
|
if res.AuthState == "1" { |
|
|
|
res.IsNeedGetEnergy = "0" |
|
|
|
} |
|
|
|
e.OutSuc(c, res, nil) |
|
|
|
return |
|
|
@@ -51,6 +68,7 @@ func RealNameSave(c *gin.Context) { |
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err) |
|
|
|
return |
|
|
|
} |
|
|
|
egg_system_rules.Init(cfg.RedisAddr) |
|
|
|
eg := db.Db |
|
|
|
user := GetUser(c) |
|
|
|
NewUserRealNameAuthDb := implement.NewUserRealNameAuthDb(eg) |
|
|
@@ -90,6 +108,14 @@ func RealNameSave(c *gin.Context) { |
|
|
|
} |
|
|
|
isNeedPay := "1" |
|
|
|
list, _ := NewUserRealNameAuthDb.GetRealNameAuthByUid(utils.Int64ToStr(user.Id)) |
|
|
|
amount := GetSysCfgStr("user_real_name_money") |
|
|
|
if list != nil && list.IsPay != 1 || list == nil { |
|
|
|
_, can := egg_energy.CheckActivityCoinToAlipayRealName(db.Db, user.Id, amount) |
|
|
|
if can == false { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "请先前往蛋蛋乐园获取能量值")) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
if list != nil { |
|
|
|
if args.RealName != list.RealName || args.CardNo != list.CardNo || list.AlipayOid == "" { |
|
|
|
list.AlipayOid = outerOrderNo |
|
|
@@ -126,6 +152,11 @@ func RealNameSave(c *gin.Context) { |
|
|
|
} |
|
|
|
//TODO 扣钱 自动用能量值抵扣 |
|
|
|
if isNeedPay == "1" { |
|
|
|
err = egg_energy.ActivityCoinToAlipayRealName(db.Db, user.Id, amount) |
|
|
|
if err != nil { |
|
|
|
e.OutErr(c, 400, err) |
|
|
|
return |
|
|
|
} |
|
|
|
list.IsPay = 1 |
|
|
|
eg.Where("id=?", list.Id).Update(list) |
|
|
|
} |
|
|
|