diff --git a/legend/common/const.go b/legend/common/const.go index 1fca375..ff779ea 100644 --- a/legend/common/const.go +++ b/legend/common/const.go @@ -1,4 +1,4 @@ package common -const ACTIVE = "ACTIVE" -const UNACTIVE = "UNACTIVE" +const ACTIVE = "active" +const UNACTIVE = "unactive" diff --git a/legend/controllers/base/baseController.go b/legend/controllers/base/baseController.go index 55d1c6d..adebb89 100644 --- a/legend/controllers/base/baseController.go +++ b/legend/controllers/base/baseController.go @@ -18,9 +18,9 @@ func (c *BasicController) Prepare() { userName, ok := c.GetSession("userName").(string) if ok { logs.Info("该用户已经登录, userName:", userName) - userInfo := fast.GetUserInfoByUserName(userName) - if userInfo.Mobile != "" { - c.Data["nickName"] = userInfo.UserName + userInfo := fast.GetMerchantInfoByUserName(userName) + if userInfo.LoginAccount != "" { + c.Data["nickName"] = userInfo.MerchantName } } else { c.Data["nickName"] = "史蒂芬-库里" diff --git a/legend/controllers/showPageController.go b/legend/controllers/showPageController.go index c7668f9..873eaad 100644 --- a/legend/controllers/showPageController.go +++ b/legend/controllers/showPageController.go @@ -1,6 +1,8 @@ package controllers import ( + "fmt" + "github.com/beego/beego/v2/core/logs" "legend/controllers/base" "legend/service" "legend/utils" @@ -21,13 +23,18 @@ func (c *ShowPageController) WelcomePage() { userName := c.GetSession("userName").(string) + fmt.Println(userName) + accountService := new(service.AccountService) accountInfo := accountService.GetAccountInfo(userName) + logs.Debug("account信息:", accountInfo) + c.Data["balance"] = accountInfo.Balance - c.Data["unBalance"] = accountInfo.Unbalance - c.Data["settleAmount"] = accountInfo.SettAmount - c.Data["todayAmount"] = accountInfo.TodayIncome + c.Data["unBalance"] = accountInfo.FreezeAmount + c.Data["settleAmount"] = accountInfo.SettleAmount + //c.Data["todayAmount"] = accountInfo.TodayIncome + // 获取今天充值金额 c.TplName = "welcome.html" } @@ -136,7 +143,7 @@ func (c *ShowPageController) PersonPage() { } else { merchantService := new(service.MerchantService) userInfo := merchantService.MerchantInfo(userName) - c.Data["userName"] = userInfo.UserName + c.Data["userName"] = userInfo.MerchantName } c.TplName = "person.html" diff --git a/legend/models/fast/Account.go b/legend/models/fast/Account.go deleted file mode 100644 index 009303d..0000000 --- a/legend/models/fast/Account.go +++ /dev/null @@ -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 -} diff --git a/legend/models/fast/UserInfo.go b/legend/models/fast/UserInfo.go deleted file mode 100644 index 0aab0f7..0000000 --- a/legend/models/fast/UserInfo.go +++ /dev/null @@ -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 -} diff --git a/legend/models/fast/accountInfoDao.go b/legend/models/fast/accountInfoDao.go new file mode 100644 index 0000000..d6b66e2 --- /dev/null +++ b/legend/models/fast/accountInfoDao.go @@ -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 +} diff --git a/legend/models/fast/orderInfoDao.go b/legend/models/fast/orderInfoDao.go new file mode 100644 index 0000000..d056cae --- /dev/null +++ b/legend/models/fast/orderInfoDao.go @@ -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 +} diff --git a/legend/models/fast/UserBankAccount.go b/legend/models/fast/userBankAccountDao.go similarity index 100% rename from legend/models/fast/UserBankAccount.go rename to legend/models/fast/userBankAccountDao.go diff --git a/legend/models/fast/userInfoDao.go b/legend/models/fast/userInfoDao.go new file mode 100644 index 0000000..ce2d3f1 --- /dev/null +++ b/legend/models/fast/userInfoDao.go @@ -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 +} diff --git a/legend/models/fast/UserPayConfig.go b/legend/models/fast/userPayConfigDao.go similarity index 100% rename from legend/models/fast/UserPayConfig.go rename to legend/models/fast/userPayConfigDao.go diff --git a/legend/models/init.go b/legend/models/init.go index 0e795f5..2acebb3 100644 --- a/legend/models/init.go +++ b/legend/models/init.go @@ -42,10 +42,10 @@ func initFastPay() { 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.RpUserBankAccount)) - orm.RegisterModel(new(fast.RpAccount)) + orm.RegisterModel(new(fast.AccountInfo)) logs.Info("init fast success ......") } @@ -72,7 +72,15 @@ func initLegend() { 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 ......") - orm.RegisterModel() } diff --git a/legend/service/accountService.go b/legend/service/accountService.go index c254cc1..1751fc7 100644 --- a/legend/service/accountService.go +++ b/legend/service/accountService.go @@ -1,15 +1,18 @@ package service -import "legend/models/fast" +import ( + "legend/models/fast" +) type AccountService struct { BaseService } -func (c *AccountService) GetAccountInfo(userName string) *fast.RpAccount { - userInfo := fast.GetUserInfoByUserName(userName) +func (c *AccountService) GetAccountInfo(userName string) *fast.AccountInfo { - accountInfo := fast.GetAccontInfo(userInfo.UserNo) + merchantInfo := fast.GetMerchantInfoByUserName(userName) + + accountInfo := fast.GetAccountInfo(merchantInfo.MerchantUid) return accountInfo } diff --git a/legend/service/loginService.go b/legend/service/loginService.go index 8b07247..cd52189 100644 --- a/legend/service/loginService.go +++ b/legend/service/loginService.go @@ -19,24 +19,25 @@ type LoginJsonData struct { } func (c *LoginService) Login(userName, password string) *LoginJsonData { + loginJsonData := new(LoginJsonData) loginJsonData.Code = 200 - userInfo := fast.GetUserInfoByUserName(userName) + userInfo := fast.GetMerchantInfoByUserName(userName) logs.Info("登录账户信息:", fmt.Sprintf("%+v", userInfo)) - if nil == userInfo || userInfo.Mobile == "" { + if nil == userInfo || userInfo.LoginAccount == "" { logs.Error("用户不存在,账户:", userName) loginJsonData.Code = 404 loginJsonData.Msg = "用户不存在" } else { - if userInfo.Status == common.UNACTIVE { + if strings.ToLower(userInfo.Status) == strings.ToLower(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.Info("账户密码md5后:", md5Password, ";数据库保存的为:", userInfo.LoginPassword) + if strings.ToLower(utils.EncodeMd5(password)) != strings.ToLower(userInfo.LoginPassword) { logs.Error("密码错误,账户:", userName) loginJsonData.Code = -1 loginJsonData.Msg = "密码错误" @@ -57,15 +58,15 @@ func (c *LoginService) PersonPassword(newPassword, oldPassword, repeatPassword, logoutJsonData := new(LoginJsonData) logoutJsonData.Code = -1 - userInfo := fast.GetUserInfoByUserName(userName) - if userInfo.Password != utils.EncodeMd5(oldPassword) { + userInfo := fast.GetMerchantInfoByUserName(userName) + if userInfo.LoginPassword != utils.EncodeMd5(oldPassword) { logoutJsonData.Msg = "旧密码输入不正确" } else if newPassword != repeatPassword { logoutJsonData.Msg = "2次密码不一致" } else { passwordMd5 := utils.EncodeMd5(newPassword) - userInfo.Password = passwordMd5 - if !fast.UpdateUserInfo(userInfo) { + userInfo.LoginPassword = passwordMd5 + if !fast.UpdateMerchantInfo(userInfo) { logoutJsonData.Msg = "密码更新失败" } else { diff --git a/legend/service/merchantService.go b/legend/service/merchantService.go index af661cd..a419b01 100644 --- a/legend/service/merchantService.go +++ b/legend/service/merchantService.go @@ -9,11 +9,11 @@ type MerchantService struct { 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) - bankInfo := fast.GetBankInfoByUserNo(userInfo.UserNo) - userPayConfig := fast.GetUserPayConfigByUserNo(userInfo.UserNo) + userInfo := fast.GetMerchantInfoByUserName(mobile) + bankInfo := fast.GetBankInfoByUserNo(userInfo.LoginAccount) + userPayConfig := fast.GetUserPayConfigByUserNo(userInfo.LoginAccount) return userInfo, bankInfo, userPayConfig } @@ -25,13 +25,13 @@ func (c *MerchantService) UserPayConfig(userName string) 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 } - userNo := userInfo.UserNo + userNo := userInfo.LoginAccount userPayConfig := fast.GetUserPayConfigByUserNo(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 { - userInfo := fast.GetUserInfoByUserName(mobile) - if nil == userInfo || userInfo.UserNo == "" { +func (c *MerchantService) MerchantInfo(mobile string) *fast.MerchantInfo { + userInfo := fast.GetMerchantInfoByUserName(mobile) + if nil == userInfo || userInfo.LoginAccount == "" { logs.Error("获取用户信息失败") } diff --git a/legend/views/index.tpl b/legend/views/index.tpl deleted file mode 100644 index 8d6fbec..0000000 --- a/legend/views/index.tpl +++ /dev/null @@ -1,95 +0,0 @@ - - - -
-