套餐查询提供状态筛选字段;实名认证回调结果提供页面
This commit is contained in:
@@ -101,6 +101,18 @@ func Identify(c *fiber.Ctx) error {
|
||||
|
||||
// endregion
|
||||
|
||||
type idenResultData struct {
|
||||
Success bool
|
||||
Message string
|
||||
}
|
||||
|
||||
func renderIdenResult(c *fiber.Ctx, success bool, message string) error {
|
||||
return c.Render("views/iden-result", idenResultData{
|
||||
Success: success,
|
||||
Message: message,
|
||||
})
|
||||
}
|
||||
|
||||
// IdentifyCallbackNew 更新用户实名认证状态
|
||||
func IdentifyCallbackNew(c *fiber.Ctx) error {
|
||||
|
||||
@@ -110,18 +122,17 @@ func IdentifyCallbackNew(c *fiber.Ctx) error {
|
||||
Success bool `json:"success" validate:"required"`
|
||||
})
|
||||
if err := c.QueryParser(req); err != nil {
|
||||
return core.NewBizErr("解析请求参数失败", err)
|
||||
return renderIdenResult(c, false, "解析请求参数失败")
|
||||
}
|
||||
|
||||
// 获取 token
|
||||
infoStr, err := g.Redis.GetDel(c.Context(), idenKey(req.Id)).Bytes()
|
||||
if err != nil {
|
||||
return core.NewBizErr("实名认证状态已失效", err)
|
||||
return renderIdenResult(c, false, "实名认证状态已失效,请重新发起认证")
|
||||
}
|
||||
info := idenInfo{}
|
||||
err = json.Unmarshal(infoStr, &info)
|
||||
if err != nil {
|
||||
return core.NewServErr("解析实名认证信息失败", err)
|
||||
if err = json.Unmarshal(infoStr, &info); err != nil {
|
||||
return renderIdenResult(c, false, "解析实名认证信息失败,请重新发起认证")
|
||||
}
|
||||
|
||||
// 获取认证结果
|
||||
@@ -131,13 +142,13 @@ func IdentifyCallbackNew(c *fiber.Ctx) error {
|
||||
info.Token,
|
||||
))
|
||||
if err != nil {
|
||||
return core.NewServErr("获取实名认证结果失败", err)
|
||||
return renderIdenResult(c, false, "获取实名认证结果失败,请重新发起认证")
|
||||
}
|
||||
if resp.Error.Code != 0 {
|
||||
return core.NewServErr(fmt.Sprintf("获取实名认证结果失败: %s", resp.Error.Message))
|
||||
return renderIdenResult(c, false, fmt.Sprintf("获取实名认证结果失败:%s", resp.Error.Message))
|
||||
}
|
||||
if resp.Result.H5Result != "ok" || resp.Result.SmResult != "ok" || resp.Result.RxResult != "ok" {
|
||||
return core.NewBizErr(fmt.Sprintf("实名认证失败: %s", resp.Result.Desc))
|
||||
return renderIdenResult(c, false, fmt.Sprintf("实名认证未通过:%s", resp.Result.Desc))
|
||||
}
|
||||
|
||||
// 更新用户实名认证状态
|
||||
@@ -150,11 +161,11 @@ func IdentifyCallbackNew(c *fiber.Ctx) error {
|
||||
q.User.IDToken.Value(info.Token),
|
||||
)
|
||||
if err != nil {
|
||||
return core.NewServErr("更新用户实名信息失败", err)
|
||||
return renderIdenResult(c, false, "保存实名认证信息失败,请联系客服处理")
|
||||
}
|
||||
|
||||
// 返回结果页面
|
||||
return c.SendString("🎉认证成功!现在可以安全关闭这个页面")
|
||||
return renderIdenResult(c, true, "实名认证成功,请在扫码页面点击按钮完成认证")
|
||||
}
|
||||
|
||||
func idenKey(id string) string {
|
||||
|
||||
@@ -55,6 +55,19 @@ func PageResourceShort(c *fiber.Ctx) error {
|
||||
if req.ExpireBefore != nil {
|
||||
do.Where(q.ResourceShort.As(q.Resource.Short.Name()).ExpireAt.Lte(*req.ExpireBefore))
|
||||
}
|
||||
if req.Status != nil {
|
||||
var short = q.ResourceShort.As(q.Resource.Short.Name())
|
||||
switch *req.Status {
|
||||
case 1:
|
||||
var timeCond = q.Resource.Where(short.Type.Eq(int(m.ResourceModeTime)), short.ExpireAt.Gte(time.Now()))
|
||||
var quotaCond = q.Resource.Where(short.Type.Eq(int(m.ResourceModeQuota)), short.Quota.GtCol(short.Used))
|
||||
do.Where(q.Resource.Where(timeCond).Or(quotaCond))
|
||||
case 2:
|
||||
var timeCond = q.Resource.Where(short.Type.Eq(int(m.ResourceModeTime)), short.ExpireAt.Lte(time.Now()))
|
||||
var quotaCond = q.Resource.Where(short.Type.Eq(int(m.ResourceModeQuota)), short.Quota.LteCol(short.Used))
|
||||
do.Where(q.Resource.Where(timeCond).Or(quotaCond))
|
||||
}
|
||||
}
|
||||
|
||||
resource, err := q.Resource.Where(do).
|
||||
Joins(q.Resource.Short).
|
||||
@@ -95,6 +108,7 @@ type PageResourceShortReq struct {
|
||||
CreateBefore *time.Time `json:"create_before"`
|
||||
ExpireAfter *time.Time `json:"expire_after"`
|
||||
ExpireBefore *time.Time `json:"expire_before"`
|
||||
Status *int `json:"status"` // 0 - 全部,1 - 有效,2 - 过期
|
||||
}
|
||||
|
||||
// PageResourceLong 分页查询当前用户长效套餐
|
||||
@@ -137,6 +151,19 @@ func PageResourceLong(c *fiber.Ctx) error {
|
||||
if req.ExpireBefore != nil {
|
||||
do.Where(q.ResourceLong.As(q.Resource.Long.Name()).ExpireAt.Lte(*req.ExpireBefore))
|
||||
}
|
||||
if req.Status != nil {
|
||||
var long = q.ResourceLong.As(q.Resource.Long.Name())
|
||||
switch *req.Status {
|
||||
case 1:
|
||||
var timeCond = q.Resource.Where(long.Type.Eq(int(m.ResourceModeTime)), long.ExpireAt.Gte(time.Now()))
|
||||
var quotaCond = q.Resource.Where(long.Type.Eq(int(m.ResourceModeQuota)), long.Quota.GtCol(long.Used))
|
||||
do.Where(q.Resource.Where(timeCond).Or(quotaCond))
|
||||
case 2:
|
||||
var timeCond = q.Resource.Where(long.Type.Eq(int(m.ResourceModeTime)), long.ExpireAt.Lte(time.Now()))
|
||||
var quotaCond = q.Resource.Where(long.Type.Eq(int(m.ResourceModeQuota)), long.Quota.LteCol(long.Used))
|
||||
do.Where(q.Resource.Where(timeCond).Or(quotaCond))
|
||||
}
|
||||
}
|
||||
|
||||
resource, err := q.Resource.Where(do).
|
||||
Joins(q.Resource.Long).
|
||||
@@ -177,6 +204,7 @@ type PageResourceLongReq struct {
|
||||
CreateBefore *time.Time `json:"create_before"`
|
||||
ExpireAfter *time.Time `json:"expire_after"`
|
||||
ExpireBefore *time.Time `json:"expire_before"`
|
||||
Status *int `json:"status"` // 0 - 全部,1 - 有效,2 - 过期
|
||||
}
|
||||
|
||||
// PageResourceShortByAdmin 分页查询全部短效套餐
|
||||
|
||||
Reference in New Issue
Block a user