mirror of
				https://github.com/kongyuebin1/dongfeng-pay.git
				synced 2025-10-31 10:37:32 +08:00 
			
		
		
		
	由gopath形式改为module
This commit is contained in:
		
							
								
								
									
										39
									
								
								legend/models/fast/Account.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								legend/models/fast/Account.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| 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 | ||||
| } | ||||
							
								
								
									
										44
									
								
								legend/models/fast/UserBankAccount.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								legend/models/fast/UserBankAccount.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | ||||
| package fast | ||||
|  | ||||
| import ( | ||||
| 	"github.com/astaxie/beego/logs" | ||||
| 	"github.com/beego/beego/v2/client/orm" | ||||
| ) | ||||
|  | ||||
| type RpUserBankAccount struct { | ||||
| 	Id              string `orm:"pk;column(id)"` | ||||
| 	CreateTime      string | ||||
| 	EditTime        string | ||||
| 	Version         string | ||||
| 	Remark          string | ||||
| 	Status          string | ||||
| 	UserNo          string | ||||
| 	BankName        string | ||||
| 	BankCode        string | ||||
| 	BankAccountName string | ||||
| 	BankAccountNo   string | ||||
| 	CardType        string | ||||
| 	CardNo          string | ||||
| 	MobileNo        string | ||||
| 	IsDefault       string | ||||
| 	Province        string | ||||
| 	City            string | ||||
| 	Areas           string | ||||
| 	Street          string | ||||
| 	BankAccountType string | ||||
| } | ||||
|  | ||||
| func (c *RpUserBankAccount) TableName() string { | ||||
| 	return "rp_user_bank_account" | ||||
| } | ||||
|  | ||||
| func GetBankInfoByUserNo(userNo string) *RpUserBankAccount { | ||||
| 	o := orm.NewOrm() | ||||
| 	userBankAccount := new(RpUserBankAccount) | ||||
| 	if _, err := o.QueryTable("rp_user_bank_account"). | ||||
| 		Filter("user_no", userNo). | ||||
| 		All(userBankAccount); err != nil { | ||||
| 		logs.Error("获取用户银行卡信息失败:", err) | ||||
| 	} | ||||
| 	return userBankAccount | ||||
| } | ||||
							
								
								
									
										58
									
								
								legend/models/fast/UserInfo.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								legend/models/fast/UserInfo.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,58 @@ | ||||
| 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 | ||||
| } | ||||
							
								
								
									
										34
									
								
								legend/models/fast/UserPayConfig.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								legend/models/fast/UserPayConfig.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| package fast | ||||
|  | ||||
| import ( | ||||
| 	"github.com/astaxie/beego/logs" | ||||
| 	"github.com/beego/beego/v2/client/orm" | ||||
| ) | ||||
|  | ||||
| type RpUserPayConfig struct { | ||||
| 	Id        string `orm:"pk;column(id)"` | ||||
| 	UserNo    string | ||||
| 	UserName  string | ||||
| 	Status    string | ||||
| 	PayKey    string | ||||
| 	PaySecret string | ||||
| } | ||||
|  | ||||
| func (c *RpUserPayConfig) TableName() string { | ||||
| 	return "rp_user_pay_config" | ||||
| } | ||||
|  | ||||
| func getTableName() string { | ||||
| 	return "rp_user_pay_config" | ||||
| } | ||||
|  | ||||
| func GetUserPayConfigByUserNo(userNo string) *RpUserPayConfig { | ||||
| 	o := orm.NewOrm() | ||||
| 	userPayConfig := new(RpUserPayConfig) | ||||
| 	_, err := o.QueryTable(getTableName()).Filter("user_no", userNo).All(userPayConfig) | ||||
| 	if err != nil { | ||||
| 		logs.Error("获取用户支付配置错误:", err) | ||||
| 	} | ||||
|  | ||||
| 	return userPayConfig | ||||
| } | ||||
							
								
								
									
										78
									
								
								legend/models/init.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								legend/models/init.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,78 @@ | ||||
| package models | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"github.com/beego/beego/v2/client/orm" | ||||
| 	"github.com/beego/beego/v2/core/logs" | ||||
| 	"github.com/beego/beego/v2/server/web" | ||||
| 	_ "github.com/go-sql-driver/mysql" | ||||
| 	"legend/models/fast" | ||||
| 	"os" | ||||
| ) | ||||
|  | ||||
| /** | ||||
| ** 链接数据库,注册已经存在的数据表,进行orm映射操作 | ||||
|  */ | ||||
| func init() { | ||||
| 	//initFastPay() | ||||
| 	initLegend() | ||||
| } | ||||
|  | ||||
| /** | ||||
| ** 初始化快付支付系统的mysql数据库 | ||||
|  */ | ||||
| func initFastPay() { | ||||
| 	dbType, _ := web.AppConfig.String("dbtype") | ||||
| 	mysqlHost, _ := web.AppConfig.String("fast::host") | ||||
| 	mysqlPort, _ := web.AppConfig.String("fast::port") | ||||
| 	mysqlUserName, _ := web.AppConfig.String("fast::username") | ||||
| 	mysqlPassword, _ := web.AppConfig.String("fast::password") | ||||
| 	mysqlDbName, _ := web.AppConfig.String("fast::dbname") | ||||
|  | ||||
| 	logs.Info("host:%s, port:%s, usreName:%s, password:%s, dbname:%s, dbType:%s", mysqlHost, mysqlPort, | ||||
| 		mysqlUserName, mysqlPassword, mysqlDbName, dbType) | ||||
|  | ||||
| 	pStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&loc=Local", | ||||
| 		mysqlUserName, mysqlPassword, mysqlHost, mysqlPort, mysqlDbName) | ||||
|  | ||||
| 	if err := orm.RegisterDataBase("default", dbType, pStr); err != nil { | ||||
| 		logs.Error("init fast fail:%s", err) | ||||
| 		os.Exit(1) | ||||
| 	} | ||||
| 	orm.SetMaxIdleConns("default", 30) | ||||
| 	orm.SetMaxIdleConns("default", 30) | ||||
|  | ||||
| 	orm.RegisterModel(new(fast.RpUserInfo)) | ||||
| 	orm.RegisterModel(new(fast.RpUserPayConfig)) | ||||
| 	orm.RegisterModel(new(fast.RpUserBankAccount)) | ||||
| 	orm.RegisterModel(new(fast.RpAccount)) | ||||
|  | ||||
| 	logs.Info("init fast success ......") | ||||
| } | ||||
|  | ||||
| /** | ||||
| ** 初始化传奇支付系统的mysql数据库 | ||||
|  */ | ||||
| func initLegend() { | ||||
| 	dbType, _ := web.AppConfig.String("dbtype") | ||||
| 	mysqlHost, _ := web.AppConfig.String("legend::host") | ||||
| 	mysqlPort, _ := web.AppConfig.String("legend::port") | ||||
| 	mysqlUserName, _ := web.AppConfig.String("legend::username") | ||||
| 	mysqlPassword, _ := web.AppConfig.String("legend::password") | ||||
| 	mysqlDbName, _ := web.AppConfig.String("legend::dbname") | ||||
|  | ||||
| 	logs.Info("host:%s, port:%s, usreName:%s, password:%s, dbname:%s", mysqlHost, mysqlPort, | ||||
| 		mysqlUserName, mysqlPassword, mysqlDbName) | ||||
|  | ||||
| 	pStr := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&loc=Local", | ||||
| 		mysqlUserName, mysqlPassword, mysqlHost, mysqlPort, mysqlDbName) | ||||
|  | ||||
| 	if err := orm.RegisterDataBase("default", dbType, pStr); err != nil { | ||||
| 		logs.Error("init legend fail:%s", err) | ||||
| 		os.Exit(1) | ||||
| 	} | ||||
|  | ||||
| 	logs.Info("init legend success ......") | ||||
|  | ||||
| 	orm.RegisterModel() | ||||
| } | ||||
		Reference in New Issue
	
	Block a user