修改传奇充值商户的账户显示

This commit is contained in:
kongyuebin 2021-04-30 15:55:02 +08:00
parent 5ee1450a21
commit c48d2f3e2c
15 changed files with 197 additions and 227 deletions

View File

@ -1,4 +1,4 @@
package common package common
const ACTIVE = "ACTIVE" const ACTIVE = "active"
const UNACTIVE = "UNACTIVE" const UNACTIVE = "unactive"

View File

@ -18,9 +18,9 @@ func (c *BasicController) Prepare() {
userName, ok := c.GetSession("userName").(string) userName, ok := c.GetSession("userName").(string)
if ok { if ok {
logs.Info("该用户已经登录, userName", userName) logs.Info("该用户已经登录, userName", userName)
userInfo := fast.GetUserInfoByUserName(userName) userInfo := fast.GetMerchantInfoByUserName(userName)
if userInfo.Mobile != "" { if userInfo.LoginAccount != "" {
c.Data["nickName"] = userInfo.UserName c.Data["nickName"] = userInfo.MerchantName
} }
} else { } else {
c.Data["nickName"] = "史蒂芬-库里" c.Data["nickName"] = "史蒂芬-库里"

View File

@ -1,6 +1,8 @@
package controllers package controllers
import ( import (
"fmt"
"github.com/beego/beego/v2/core/logs"
"legend/controllers/base" "legend/controllers/base"
"legend/service" "legend/service"
"legend/utils" "legend/utils"
@ -21,13 +23,18 @@ func (c *ShowPageController) WelcomePage() {
userName := c.GetSession("userName").(string) userName := c.GetSession("userName").(string)
fmt.Println(userName)
accountService := new(service.AccountService) accountService := new(service.AccountService)
accountInfo := accountService.GetAccountInfo(userName) accountInfo := accountService.GetAccountInfo(userName)
logs.Debug("account信息", accountInfo)
c.Data["balance"] = accountInfo.Balance c.Data["balance"] = accountInfo.Balance
c.Data["unBalance"] = accountInfo.Unbalance c.Data["unBalance"] = accountInfo.FreezeAmount
c.Data["settleAmount"] = accountInfo.SettAmount c.Data["settleAmount"] = accountInfo.SettleAmount
c.Data["todayAmount"] = accountInfo.TodayIncome //c.Data["todayAmount"] = accountInfo.TodayIncome
// 获取今天充值金额
c.TplName = "welcome.html" c.TplName = "welcome.html"
} }
@ -136,7 +143,7 @@ func (c *ShowPageController) PersonPage() {
} else { } else {
merchantService := new(service.MerchantService) merchantService := new(service.MerchantService)
userInfo := merchantService.MerchantInfo(userName) userInfo := merchantService.MerchantInfo(userName)
c.Data["userName"] = userInfo.UserName c.Data["userName"] = userInfo.MerchantName
} }
c.TplName = "person.html" c.TplName = "person.html"

View File

@ -1,39 +0,0 @@
package fast
import (
"github.com/astaxie/beego/logs"
"github.com/beego/beego/v2/client/orm"
)
type RpAccount struct {
Id string `orm:"pk;column(id)"`
CreateTime string
EditTime string
Version int
Remark string
AccountNo string
Balance float64
Unbalance float64
SecurityMoney float64
Status string
TotalIncome float64
TodayIncome float64
SettAmount float64
UserNo string
AmountFrozen float64
}
func (c *RpAccount) TableName() string {
return "rp_account"
}
func GetAccontInfo(userNo string) *RpAccount {
o := orm.NewOrm()
rpAccount := new(RpAccount)
if _, err := o.QueryTable("rp_account").Filter("user_no", userNo).All(rpAccount); err != nil {
logs.Error("获取account信息失败", err)
}
return rpAccount
}

View File

@ -1,58 +0,0 @@
package fast
import (
"github.com/astaxie/beego/logs"
"github.com/beego/beego/v2/client/orm"
)
type RpUserInfo struct {
Id string `orm:"pk;column(id)"`
CreateTime string
Status string
UserNo string
UserName string
AccountNo string
Mobile string
Password string
PayPwd string
LastSmsVerifyCodeTime string
Email string
Ips string
}
func (c *RpUserInfo) TableName() string {
return "rp_user_info"
}
func tableName() string {
return "rp_user_info"
}
func GetUserInfoByUserName(userName string) *RpUserInfo {
o := orm.NewOrm()
userInfo := new(RpUserInfo)
_, err := o.QueryTable(tableName()).Filter("mobile", userName).All(userInfo)
if err != nil {
logs.Error("根据用户名从数据获取用户信息失败:", err)
}
return userInfo
}
/**
** 更新用户信息
*/
func UpdateUserInfo(userInfo *RpUserInfo) bool {
o := orm.NewOrm()
if _, err := o.Update(userInfo); err != nil {
logs.Error("更新用户信息失败,错误:%s", err)
return false
}
return true
}

View File

@ -0,0 +1,38 @@
package fast
import (
"github.com/astaxie/beego/logs"
"github.com/beego/beego/v2/client/orm"
)
type AccountInfo struct {
Id string `orm:"pk;column(id)"`
Status string
AccountUid string
AccountName string
Balance float64
SettleAmount float64
LoanAmount float64
WaitAmount float64
FreezeAmount float64
PayforAmount float64
UpdateTime string
CreateTime string
}
const ACCOUNTINFO = "account_info"
func (c *AccountInfo) TableName() string {
return "account_info"
}
func GetAccountInfo(accountUid string) *AccountInfo {
o := orm.NewOrm()
account := new(AccountInfo)
if _, err := o.QueryTable(ACCOUNTINFO).Filter("account_uid", accountUid).All(account); err != nil {
logs.Error("获取account信息失败", err)
}
return account
}

View File

@ -0,0 +1,38 @@
package fast
type OrderInfo struct {
Id string `orm:"pk;column(id)"`
MerchantOrderId string
ShopName string
OrderPeriod string
BankOrderId string
BankTransId string
OrderAmount float64
ShowAmount float64
FactAmount float64
RollPoolCode string
RollPoolName string
RoadUid string
RoadName string
PayProductCode string
PayProductName string
PayTypeCode string
PayTypeName string
OsType string
Status string
Refund string
RefundTime string
Freeze string
FreezeTime string
Unfreeze string
UnfreezeTime string
ReturnUrl string
NotifyUrl string
MerchantUid string
MerchantName string
AgentUid string
AgentName string
Response string
UpdateTime string
CreateTime string
}

View File

@ -0,0 +1,67 @@
package fast
import (
"github.com/astaxie/beego/logs"
"github.com/beego/beego/v2/client/orm"
)
type MerchantInfo struct {
Id string `orm:"pk;column(id)"`
Status string
BelongAgentUid string
BelongAgentName string
MerchantName string
MerchantUid string
MerchantKey string
MerchantSecret string
LoginAccount string
LoginPassword string
AutoSettle string
AutoPayFor string
WhiteIps string
Remark string
SinglePayForRoadUid string
SinglePayForRoadName string
RollPayForRoadCode string
RollPayForRoadName string
PayforFee string
CreateTime string
UpdateTime string
}
func (c *MerchantInfo) TableName() string {
return "merchant_info"
}
func tableName() string {
return "merchant_info"
}
func GetMerchantInfoByUserName(userName string) *MerchantInfo {
o := orm.NewOrm()
userInfo := new(MerchantInfo)
_, err := o.QueryTable(tableName()).Filter("login_account", userName).All(userInfo)
if err != nil {
logs.Error("根据用户名从数据获取用户信息失败:", err)
}
return userInfo
}
/**
** 更新用户信息
*/
func UpdateMerchantInfo(merchantInfo *MerchantInfo) bool {
o := orm.NewOrm()
if _, err := o.Update(merchantInfo); err != nil {
logs.Error("更新用户信息失败,错误:%s", err)
return false
}
return true
}

View File

@ -42,10 +42,10 @@ func initFastPay() {
orm.SetMaxIdleConns("default", 30) orm.SetMaxIdleConns("default", 30)
orm.SetMaxIdleConns("default", 30) orm.SetMaxIdleConns("default", 30)
orm.RegisterModel(new(fast.RpUserInfo)) orm.RegisterModel(new(fast.MerchantInfo))
orm.RegisterModel(new(fast.RpUserPayConfig)) orm.RegisterModel(new(fast.RpUserPayConfig))
orm.RegisterModel(new(fast.RpUserBankAccount)) orm.RegisterModel(new(fast.RpUserBankAccount))
orm.RegisterModel(new(fast.RpAccount)) orm.RegisterModel(new(fast.AccountInfo))
logs.Info("init fast success ......") logs.Info("init fast success ......")
} }
@ -72,7 +72,15 @@ func initLegend() {
os.Exit(1) os.Exit(1)
} }
orm.SetMaxIdleConns("default", 30)
orm.SetMaxIdleConns("default", 30)
orm.RegisterModel(new(fast.MerchantInfo))
orm.RegisterModel(new(fast.RpUserPayConfig))
orm.RegisterModel(new(fast.RpUserBankAccount))
orm.RegisterModel(new(fast.AccountInfo))
orm.RegisterModel(new(fast.OrderInfo))
logs.Info("init legend success ......") logs.Info("init legend success ......")
orm.RegisterModel()
} }

View File

@ -1,15 +1,18 @@
package service package service
import "legend/models/fast" import (
"legend/models/fast"
)
type AccountService struct { type AccountService struct {
BaseService BaseService
} }
func (c *AccountService) GetAccountInfo(userName string) *fast.RpAccount { func (c *AccountService) GetAccountInfo(userName string) *fast.AccountInfo {
userInfo := fast.GetUserInfoByUserName(userName)
accountInfo := fast.GetAccontInfo(userInfo.UserNo) merchantInfo := fast.GetMerchantInfoByUserName(userName)
accountInfo := fast.GetAccountInfo(merchantInfo.MerchantUid)
return accountInfo return accountInfo
} }

View File

@ -19,24 +19,25 @@ type LoginJsonData struct {
} }
func (c *LoginService) Login(userName, password string) *LoginJsonData { func (c *LoginService) Login(userName, password string) *LoginJsonData {
loginJsonData := new(LoginJsonData) loginJsonData := new(LoginJsonData)
loginJsonData.Code = 200 loginJsonData.Code = 200
userInfo := fast.GetUserInfoByUserName(userName) userInfo := fast.GetMerchantInfoByUserName(userName)
logs.Info("登录账户信息:", fmt.Sprintf("%+v", userInfo)) logs.Info("登录账户信息:", fmt.Sprintf("%+v", userInfo))
if nil == userInfo || userInfo.Mobile == "" { if nil == userInfo || userInfo.LoginAccount == "" {
logs.Error("用户不存在,账户:", userName) logs.Error("用户不存在,账户:", userName)
loginJsonData.Code = 404 loginJsonData.Code = 404
loginJsonData.Msg = "用户不存在" loginJsonData.Msg = "用户不存在"
} else { } else {
if userInfo.Status == common.UNACTIVE { if strings.ToLower(userInfo.Status) == strings.ToLower(common.UNACTIVE) {
logs.Warn("账号异常,请联系管理员,账号:", userName) logs.Warn("账号异常,请联系管理员,账号:", userName)
loginJsonData.Code = 503 loginJsonData.Code = 503
loginJsonData.Msg = "账户已经被冻结" loginJsonData.Msg = "账户已经被冻结"
} else { } else {
md5Password := utils.EncodeMd5(password) md5Password := utils.EncodeMd5(password)
logs.Info("账户密码md5后", md5Password, ";数据库保存的为:", userInfo.Password) logs.Info("账户密码md5后", md5Password, ";数据库保存的为:", userInfo.LoginPassword)
if strings.ToLower(utils.EncodeMd5(password)) != strings.ToLower(userInfo.Password) { if strings.ToLower(utils.EncodeMd5(password)) != strings.ToLower(userInfo.LoginPassword) {
logs.Error("密码错误,账户:", userName) logs.Error("密码错误,账户:", userName)
loginJsonData.Code = -1 loginJsonData.Code = -1
loginJsonData.Msg = "密码错误" loginJsonData.Msg = "密码错误"
@ -57,15 +58,15 @@ func (c *LoginService) PersonPassword(newPassword, oldPassword, repeatPassword,
logoutJsonData := new(LoginJsonData) logoutJsonData := new(LoginJsonData)
logoutJsonData.Code = -1 logoutJsonData.Code = -1
userInfo := fast.GetUserInfoByUserName(userName) userInfo := fast.GetMerchantInfoByUserName(userName)
if userInfo.Password != utils.EncodeMd5(oldPassword) { if userInfo.LoginPassword != utils.EncodeMd5(oldPassword) {
logoutJsonData.Msg = "旧密码输入不正确" logoutJsonData.Msg = "旧密码输入不正确"
} else if newPassword != repeatPassword { } else if newPassword != repeatPassword {
logoutJsonData.Msg = "2次密码不一致" logoutJsonData.Msg = "2次密码不一致"
} else { } else {
passwordMd5 := utils.EncodeMd5(newPassword) passwordMd5 := utils.EncodeMd5(newPassword)
userInfo.Password = passwordMd5 userInfo.LoginPassword = passwordMd5
if !fast.UpdateUserInfo(userInfo) { if !fast.UpdateMerchantInfo(userInfo) {
logoutJsonData.Msg = "密码更新失败" logoutJsonData.Msg = "密码更新失败"
} else { } else {

View File

@ -9,11 +9,11 @@ type MerchantService struct {
BaseService BaseService
} }
func (c *MerchantService) GetMerchantBankInfo(mobile string) (*fast.RpUserInfo, *fast.RpUserBankAccount, *fast.RpUserPayConfig) { func (c *MerchantService) GetMerchantBankInfo(mobile string) (*fast.MerchantInfo, *fast.RpUserBankAccount, *fast.RpUserPayConfig) {
userInfo := fast.GetUserInfoByUserName(mobile) userInfo := fast.GetMerchantInfoByUserName(mobile)
bankInfo := fast.GetBankInfoByUserNo(userInfo.UserNo) bankInfo := fast.GetBankInfoByUserNo(userInfo.LoginAccount)
userPayConfig := fast.GetUserPayConfigByUserNo(userInfo.UserNo) userPayConfig := fast.GetUserPayConfigByUserNo(userInfo.LoginAccount)
return userInfo, bankInfo, userPayConfig return userInfo, bankInfo, userPayConfig
} }
@ -25,13 +25,13 @@ func (c *MerchantService) UserPayConfig(userName string) map[string]string {
merchantMapData := make(map[string]string) merchantMapData := make(map[string]string)
userInfo := fast.GetUserInfoByUserName(userName) userInfo := fast.GetMerchantInfoByUserName(userName)
if userInfo == nil || userInfo.Mobile == "" { if userInfo == nil || userInfo.LoginAccount == "" {
return merchantMapData return merchantMapData
} }
userNo := userInfo.UserNo userNo := userInfo.LoginAccount
userPayConfig := fast.GetUserPayConfigByUserNo(userNo) userPayConfig := fast.GetUserPayConfigByUserNo(userNo)
if nil == userPayConfig || userPayConfig.UserNo == "" { if nil == userPayConfig || userPayConfig.UserNo == "" {
@ -44,9 +44,9 @@ func (c *MerchantService) UserPayConfig(userName string) map[string]string {
/** /**
** 获取商户信息 ** 获取商户信息
*/ */
func (c *MerchantService) MerchantInfo(mobile string) *fast.RpUserInfo { func (c *MerchantService) MerchantInfo(mobile string) *fast.MerchantInfo {
userInfo := fast.GetUserInfoByUserName(mobile) userInfo := fast.GetMerchantInfoByUserName(mobile)
if nil == userInfo || userInfo.UserNo == "" { if nil == userInfo || userInfo.LoginAccount == "" {
logs.Error("获取用户信息失败") logs.Error("获取用户信息失败")
} }

File diff suppressed because one or more lines are too long