Browse Source

实名认证

master
huangjiajun 5 days ago
parent
commit
db7c306fe9
3 changed files with 35 additions and 3 deletions
  1. +2
    -1
      app/md/realname_auth_base.go
  2. +32
    -1
      app/svc/svc_user_real_name.go
  3. +1
    -1
      go.mod

+ 2
- 1
app/md/realname_auth_base.go View File

@@ -1,7 +1,8 @@
package md

type RealNameAuthBasicData struct {
AuthState string `json:"auth_state" example:"0未申请 1申请通过 3申请失败"`
AuthState string `json:"auth_state" example:"0未申请 1申请通过 3申请失败"`
IsNeedGetEnergy string `json:"is_need_get_energy" example:"0不需要获取能量 1弹窗提示 前往蛋蛋乐园获取能量"`
}
type RealNameAuthAddRequest struct {
RealName string `json:"real_name"`


+ 32
- 1
app/svc/svc_user_real_name.go View File

@@ -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)
}


+ 1
- 1
go.mod View File

@@ -32,7 +32,7 @@ require (

require (
code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241128142331-4b15dd7d7320
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241128142302-9a10ec776ef8
code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241129083357-e0e1afc0ff46
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5
github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible


Loading…
Cancel
Save