mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-12-13 04:19:57 +08:00
由gopath形式改为module形式
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
package filter
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/adapter/logs"
|
||||
"github.com/beego/beego/v2/server/web/context"
|
||||
"strings"
|
||||
)
|
||||
|
||||
/**
|
||||
** 对所有的用户请求进行登录判断,如果未登录跳转到登录页面
|
||||
** 但是对登录请求不进行过滤
|
||||
*/
|
||||
var LoginFilter = func(ctx *context.Context) {
|
||||
|
||||
_, ok := ctx.Input.Session("userName").(string)
|
||||
if !ok {
|
||||
if !strings.Contains(ctx.Request.RequestURI, "/login") {
|
||||
ctx.Redirect(302, "/login.html")
|
||||
} else {
|
||||
logs.Info("该用户没有登录.......")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package service
|
||||
|
||||
import "merchant/models/fast"
|
||||
|
||||
type AccountService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
func (c *AccountService) GetAccountInfo(userName string) *fast.RpAccount {
|
||||
userInfo := fast.GetUserInfoByUserName(userName)
|
||||
|
||||
accountInfo := fast.GetAccontInfo(userInfo.UserNo)
|
||||
|
||||
return accountInfo
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package service
|
||||
|
||||
type BaseService struct {
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/adapter/logs"
|
||||
"merchant/common"
|
||||
"merchant/models/fast"
|
||||
"merchant/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type LoginService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
type LoginJsonData struct {
|
||||
Code int
|
||||
Msg string
|
||||
}
|
||||
|
||||
func (c *LoginService) Login(userName, password string) *LoginJsonData {
|
||||
loginJsonData := new(LoginJsonData)
|
||||
loginJsonData.Code = 200
|
||||
|
||||
userInfo := fast.GetUserInfoByUserName(userName)
|
||||
logs.Info("登录账户信息:", fmt.Sprintf("%+v", userInfo))
|
||||
if nil == userInfo || userInfo.Mobile == "" {
|
||||
logs.Error("用户不存在,账户:", userName)
|
||||
loginJsonData.Code = 404
|
||||
loginJsonData.Msg = "用户不存在"
|
||||
} else {
|
||||
if userInfo.Status == common.UNACTIVE {
|
||||
logs.Warn("账号异常,请联系管理员,账号:", userName)
|
||||
loginJsonData.Code = 503
|
||||
loginJsonData.Msg = "账户已经被冻结"
|
||||
} else {
|
||||
md5Password := utils.EncodeMd5(password)
|
||||
logs.Info("账户密码md5后:", md5Password, ";数据库保存的为:", userInfo.Password)
|
||||
if strings.ToLower(utils.EncodeMd5(password)) != strings.ToLower(userInfo.Password) {
|
||||
logs.Error("密码错误,账户:", userName)
|
||||
loginJsonData.Code = -1
|
||||
loginJsonData.Msg = "密码错误"
|
||||
} else {
|
||||
logs.Info("登录成功")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return loginJsonData
|
||||
}
|
||||
|
||||
/**
|
||||
** 更新用户的登录密码
|
||||
*/
|
||||
func (c *LoginService) PersonPassword(newPassword, oldPassword, repeatPassword, userName string) *LoginJsonData {
|
||||
|
||||
logoutJsonData := new(LoginJsonData)
|
||||
logoutJsonData.Code = -1
|
||||
|
||||
userInfo := fast.GetUserInfoByUserName(userName)
|
||||
if userInfo.Password != utils.EncodeMd5(oldPassword) {
|
||||
logoutJsonData.Msg = "旧密码输入不正确"
|
||||
} else if newPassword != repeatPassword {
|
||||
logoutJsonData.Msg = "2次密码不一致"
|
||||
} else {
|
||||
passwordMd5 := utils.EncodeMd5(newPassword)
|
||||
userInfo.Password = passwordMd5
|
||||
if !fast.UpdateUserInfo(userInfo) {
|
||||
logoutJsonData.Msg = "密码更新失败"
|
||||
} else {
|
||||
|
||||
logoutJsonData.Code = 200
|
||||
}
|
||||
}
|
||||
|
||||
return logoutJsonData
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package service
|
||||
|
||||
type LogoutService struct {
|
||||
BaseService
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"merchant/models/fast"
|
||||
)
|
||||
|
||||
type MerchantService struct {
|
||||
BaseService
|
||||
}
|
||||
|
||||
func (c *MerchantService) GetMerchantBankInfo(mobile string) (*fast.RpUserInfo, *fast.RpUserBankAccount, *fast.RpUserPayConfig) {
|
||||
|
||||
userInfo := fast.GetUserInfoByUserName(mobile)
|
||||
bankInfo := fast.GetBankInfoByUserNo(userInfo.UserNo)
|
||||
userPayConfig := fast.GetUserPayConfigByUserNo(userInfo.UserNo)
|
||||
|
||||
return userInfo, bankInfo, userPayConfig
|
||||
}
|
||||
|
||||
/**
|
||||
** 获取商户的密钥等信息
|
||||
*/
|
||||
func (c *MerchantService) UserPayConfig(userName string) map[string]string {
|
||||
|
||||
merchantMapData := make(map[string]string)
|
||||
|
||||
userInfo := fast.GetUserInfoByUserName(userName)
|
||||
|
||||
if userInfo == nil || userInfo.Mobile == "" {
|
||||
return merchantMapData
|
||||
}
|
||||
|
||||
userNo := userInfo.UserNo
|
||||
|
||||
userPayConfig := fast.GetUserPayConfigByUserNo(userNo)
|
||||
if nil == userPayConfig || userPayConfig.UserNo == "" {
|
||||
return merchantMapData
|
||||
}
|
||||
|
||||
return merchantMapData
|
||||
}
|
||||
|
||||
/**
|
||||
** 获取商户信息
|
||||
*/
|
||||
func (c *MerchantService) MerchantInfo(mobile string) *fast.RpUserInfo {
|
||||
userInfo := fast.GetUserInfoByUserName(mobile)
|
||||
if nil == userInfo || userInfo.UserNo == "" {
|
||||
logs.Error("获取用户信息失败")
|
||||
}
|
||||
|
||||
//logs.Debug("用户信息:", userInfo)
|
||||
return userInfo
|
||||
}
|
||||
Reference in New Issue
Block a user