mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-09-18 06:39:12 +08:00
由gopath形式改为module
This commit is contained in:
15
legend/service/accountService.go
Normal file
15
legend/service/accountService.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package service
|
||||
|
||||
import "legend/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
|
||||
}
|
4
legend/service/baseService.go
Normal file
4
legend/service/baseService.go
Normal file
@@ -0,0 +1,4 @@
|
||||
package service
|
||||
|
||||
type BaseService struct {
|
||||
}
|
77
legend/service/loginService.go
Normal file
77
legend/service/loginService.go
Normal file
@@ -0,0 +1,77 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/adapter/logs"
|
||||
"legend/common"
|
||||
"legend/models/fast"
|
||||
"legend/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
|
||||
}
|
5
legend/service/logoutService.go
Normal file
5
legend/service/logoutService.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package service
|
||||
|
||||
type LogoutService struct {
|
||||
BaseService
|
||||
}
|
55
legend/service/merchantService.go
Normal file
55
legend/service/merchantService.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/astaxie/beego/logs"
|
||||
"legend/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