mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-08-18 11:41:59 +08:00
重构gateway和shop模拟商城
This commit is contained in:
@@ -1,119 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/16 11:11
|
||||
** @Author : yuebin
|
||||
** @File : account
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/16 11:11
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type AccountInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
AccountUid string
|
||||
AccountName string
|
||||
Balance float64 //账户总余额
|
||||
SettleAmount float64 //已经结算的金额
|
||||
LoanAmount float64 //账户押款金额
|
||||
FreezeAmount float64 //账户冻结金额
|
||||
WaitAmount float64 //待结算资金
|
||||
PayforAmount float64 //代付在途金额
|
||||
//AbleBalance float64 //账户可用金额
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ACCOUNT_INFO = "account_info"
|
||||
|
||||
func InsetAcount(account AccountInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&account)
|
||||
if err != nil {
|
||||
logs.Error("insert account fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetAccountByUid(accountUid string) AccountInfo {
|
||||
o := orm.NewOrm()
|
||||
var account AccountInfo
|
||||
_, err := o.QueryTable(ACCOUNT_INFO).Filter("account_uid", accountUid).Limit(1).All(&account)
|
||||
if err != nil {
|
||||
logs.Error("get account by uid fail: ", err)
|
||||
}
|
||||
|
||||
return account
|
||||
}
|
||||
|
||||
func GetAccountLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ACCOUNT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Limit(-1).OrderBy("-update_time").Count()
|
||||
if err != nil {
|
||||
logs.Error("get account len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetAccountByMap(params map[string]string, displayCount, offset int) []AccountInfo {
|
||||
o := orm.NewOrm()
|
||||
var accountList []AccountInfo
|
||||
qs := o.QueryTable(ACCOUNT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&accountList)
|
||||
if err != nil {
|
||||
logs.Error("get account by map fail: ", err)
|
||||
}
|
||||
return accountList
|
||||
}
|
||||
|
||||
func GetAllAccount() []AccountInfo {
|
||||
o := orm.NewOrm()
|
||||
var accountList []AccountInfo
|
||||
|
||||
_, err := o.QueryTable(ACCOUNT_INFO).Limit(-1).All(&accountList)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get all account fail: ", err)
|
||||
}
|
||||
|
||||
return accountList
|
||||
}
|
||||
|
||||
func UpdateAccount(account AccountInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&account)
|
||||
if err != nil {
|
||||
logs.Error("update account fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteAccountByUid(accountUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(ACCOUNT_INFO).Filter("account_uid", accountUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete account fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,69 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/19 14:56
|
||||
** @Author : yuebin
|
||||
** @File : account_history_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/19 14:56
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type AccountHistoryInfo struct {
|
||||
Id int
|
||||
AccountUid string
|
||||
AccountName string
|
||||
Type string
|
||||
Amount float64
|
||||
Balance float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ACCOUNT_HISTORY_INFO = "account_history_info"
|
||||
|
||||
func InsertAccountHistory(accountHistory AccountHistoryInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(accountHistory)
|
||||
if err != nil {
|
||||
logs.Error("insert account history fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetAccountHistoryLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ACCOUNT_HISTORY_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Limit(-1).Count()
|
||||
if err != nil {
|
||||
logs.Error("get account history len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetAccountHistoryByMap(params map[string]string, displayCount, offset int) []AccountHistoryInfo {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ACCOUNT_HISTORY_INFO)
|
||||
var accountHistoryList []AccountHistoryInfo
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&accountHistoryList)
|
||||
if err != nil {
|
||||
logs.Error("get account history by map fail: ", err)
|
||||
}
|
||||
return accountHistoryList
|
||||
}
|
@@ -1,162 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/9/19 14:41
|
||||
** @Author : yuebin
|
||||
** @File : agent_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/9/19 14:41
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type AgentInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
AgentName string
|
||||
AgentPassword string
|
||||
PayPassword string
|
||||
AgentRemark string
|
||||
AgentUid string
|
||||
AgentPhone string
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const AGENT_INFO = "agent_info"
|
||||
|
||||
func IsEixstByAgentName(agentName string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(AGENT_INFO).Filter("agent_name", agentName).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistByAgentUid(uid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(AGENT_INFO).Filter("agent_uid", uid).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsEixstByAgentPhone(agentPhone string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(AGENT_INFO).Filter("agent_phone", agentPhone).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func InsertAgentInfo(agentInfo AgentInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&agentInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert agent info fail: ", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func GetAgentInfoByAgentUid(agentUid string) AgentInfo {
|
||||
o := orm.NewOrm()
|
||||
var agentInfo AgentInfo
|
||||
_, err := o.QueryTable(AGENT_INFO).Filter("agent_uid", agentUid).Limit(1).All(&agentInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get agent info by agentUid fail: ", err)
|
||||
}
|
||||
|
||||
return agentInfo
|
||||
}
|
||||
|
||||
func GetAgentInfoByPhone(phone string) AgentInfo {
|
||||
o := orm.NewOrm()
|
||||
var agentInfo AgentInfo
|
||||
_, err := o.QueryTable(AGENT_INFO).Filter("agent_phone", phone).Limit(1).All(&agentInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get agent info by phone fail: ", err)
|
||||
}
|
||||
|
||||
return agentInfo
|
||||
}
|
||||
|
||||
func GetAgentInfoLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(AGENT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Limit(-1).Count()
|
||||
if err != nil {
|
||||
logs.Error("get agentinfo len by map fail: ", err)
|
||||
}
|
||||
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetAgentInfoByMap(params map[string]string, displayCount, offset int) []AgentInfo {
|
||||
o := orm.NewOrm()
|
||||
var agentInfoList []AgentInfo
|
||||
|
||||
qs := o.QueryTable(AGENT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&agentInfoList)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get agentInfo by map fail: ", err)
|
||||
}
|
||||
|
||||
return agentInfoList
|
||||
}
|
||||
|
||||
func GetAllAgentByMap(parmas map[string]string) []AgentInfo {
|
||||
o := orm.NewOrm()
|
||||
var agentList []AgentInfo
|
||||
|
||||
qs := o.QueryTable(AGENT_INFO)
|
||||
for k, v := range parmas {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := qs.Limit(-1).All(&agentList)
|
||||
if err != nil {
|
||||
logs.Error("get all agent by map fail: ", err)
|
||||
}
|
||||
|
||||
return agentList
|
||||
}
|
||||
|
||||
func UpdateAgentInfo(agentInfo AgentInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&agentInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update agentinfo fail: ", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteAgentByAgentUid(agentUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(AGENT_INFO).Filter("agent_uid", agentUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete agent by agent uid fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,13 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/12/17 17:50
|
||||
** @Author : yuebin
|
||||
** @File : agent_profit
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/12/17 17:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
type AgentProfit struct {
|
||||
}
|
@@ -1,106 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/9/6 10:19
|
||||
** @Author : yuebin
|
||||
** @File : bank_card_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/9/6 10:19
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type BankCardInfo struct {
|
||||
Id int
|
||||
Uid string
|
||||
UserName string
|
||||
BankName string
|
||||
BankCode string
|
||||
BankAccountType string
|
||||
AccountName string
|
||||
BankNo string
|
||||
IdentifyCard string
|
||||
CertificateNo string
|
||||
PhoneNo string
|
||||
BankAddress string
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const BANK_CARD_INFO = "bank_card_info"
|
||||
|
||||
func InsertBankCardInfo(bankCardInfo BankCardInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&bankCardInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("insert bank card info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetBankCardLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(BANK_CARD_INFO)
|
||||
for k, v := range params {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
cnt, err := qs.Limit(-1).Count()
|
||||
if err != nil {
|
||||
logs.Error("get bank card len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetBankCardByMap(params map[string]string, displayCount, offset int) []BankCardInfo {
|
||||
o := orm.NewOrm()
|
||||
var bankCardList []BankCardInfo
|
||||
qs := o.QueryTable(BANK_CARD_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&bankCardList)
|
||||
if err != nil {
|
||||
logs.Error("get bank card by map fail: ", err)
|
||||
}
|
||||
return bankCardList
|
||||
}
|
||||
|
||||
func GetBankCardByUid(uid string) BankCardInfo {
|
||||
o := orm.NewOrm()
|
||||
var bankCardInfo BankCardInfo
|
||||
_, err := o.QueryTable(bankCardInfo).Filter("uid", uid).Limit(1).All(&bankCardInfo)
|
||||
if err != nil {
|
||||
logs.Error("get bank card by uid fail: ", err)
|
||||
}
|
||||
|
||||
return bankCardInfo
|
||||
}
|
||||
|
||||
func DeleteBankCardByUid(uid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(BANK_CARD_INFO).Filter("uid", uid).Delete()
|
||||
|
||||
if err != nil {
|
||||
logs.Error("delete bank card by uid fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdateBankCard(bankCard BankCardInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&bankCard)
|
||||
if err != nil {
|
||||
logs.Error("update bank card fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,179 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/21 9:33
|
||||
** @Author : yuebin
|
||||
** @File : menu_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/21 9:33
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type MenuInfo struct {
|
||||
Id int
|
||||
MenuOrder int
|
||||
MenuUid string
|
||||
FirstMenu string
|
||||
SecondMenu string
|
||||
Creater string
|
||||
Status string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
//实现排序的三个接口函数
|
||||
type MenuInfoSlice []MenuInfo
|
||||
|
||||
func (m MenuInfoSlice) Len() int {
|
||||
return len(m)
|
||||
}
|
||||
|
||||
func (m MenuInfoSlice) Swap(i, j int) {
|
||||
m[i], m[j] = m[j], m[i]
|
||||
}
|
||||
|
||||
func (m MenuInfoSlice) Less(i, j int) bool {
|
||||
return m[i].MenuOrder < m[j].MenuOrder //从小到大排序
|
||||
}
|
||||
|
||||
const MENUINFO = "menu_info"
|
||||
|
||||
func InsertMenu(menuInfo MenuInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert new menu info fail:", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func FirstMenuIsExists(firstMenu string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("first_menu", firstMenu).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func FirstMenuUidIsExists(firstMenUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("menu_uid", firstMenUid).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func MenuOrderIsExists(menuOrder int) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MENUINFO).Filter("menu_order", menuOrder).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetMenuLen() int {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.QueryTable(MENUINFO).Count()
|
||||
if err != nil {
|
||||
logs.Error("get menu info len length fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMenuInfoByMenuUid(menuUid string) MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfo MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Filter("menu_uid", menuUid).Limit(1).All(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("get menu info by menuUid fail: ", err)
|
||||
}
|
||||
return menuInfo
|
||||
}
|
||||
|
||||
func GetMenuInfosByMenuUids(menuUids []string) []MenuInfo {
|
||||
menuInfoList := make([]MenuInfo, 0)
|
||||
for _, v := range menuUids {
|
||||
m := GetMenuInfoByMenuUid(v)
|
||||
menuInfoList = append(menuInfoList, m)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuInfoByMenuOrder(menuOrder int) MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfo MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Filter("menu_order", menuOrder).Limit(1).All(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("get menu info by menu order fail: ", err)
|
||||
}
|
||||
return menuInfo
|
||||
}
|
||||
|
||||
func GetMenuAll() []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).OrderBy("-update_time").All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get all menu list fail:", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuOffset(displayCount, offset int) []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
_, err := o.QueryTable(MENUINFO).Limit(displayCount, offset).All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get menu offset fail: ", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuOffsetByMap(params map[string]string, displayCount, offset int) []MenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var menuInfoList []MenuInfo
|
||||
qs := o.QueryTable(MENUINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&menuInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get menu offset by map fail: ", err)
|
||||
}
|
||||
return menuInfoList
|
||||
}
|
||||
|
||||
func GetMenuLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MENUINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Count()
|
||||
if err != nil {
|
||||
logs.Error("get menu len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func UpdateMenuInfo(menuInfo MenuInfo) {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.Update(&menuInfo)
|
||||
if err != nil {
|
||||
logs.Error("update menu info fail: ", err)
|
||||
}
|
||||
logs.Info("update menu info success, num: ", cnt)
|
||||
}
|
||||
|
||||
func DeleteMenuInfo(menuUid string) {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.QueryTable(MENUINFO).Filter("menu_uid", menuUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete menu info fail: ", err)
|
||||
}
|
||||
logs.Info("delete menu info num: ", cnt)
|
||||
}
|
@@ -1,135 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/7 11:52
|
||||
** @Author : yuebin
|
||||
** @File : merchant_deploy_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/7 11:52
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type MerchantDeployInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
MerchantUid string
|
||||
PayType string
|
||||
SingleRoadUid string
|
||||
SingleRoadName string
|
||||
SingleRoadPlatformRate float64
|
||||
SingleRoadAgentRate float64
|
||||
RollRoadCode string
|
||||
RollRoadName string
|
||||
RollRoadPlatformRate float64
|
||||
RollRoadAgentRate float64
|
||||
IsLoan string
|
||||
LoanRate float64
|
||||
LoanDays int
|
||||
UnfreezeHour int
|
||||
WaitUnfreezeAmount float64
|
||||
LoanAmount float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const MERCHANT_DEPLOY_INFO = "merchant_deploy_info"
|
||||
|
||||
func InsertMerchantDeployInfo(merchantDeployInfo MerchantDeployInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&merchantDeployInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert merchant deploy info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func IsExistByUidAndPayType(uid, payType string) bool {
|
||||
o := orm.NewOrm()
|
||||
isEixst := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).Filter("pay_type", payType).Exist()
|
||||
return isEixst
|
||||
}
|
||||
|
||||
func GetMerchantDeployByUidAndPayType(uid, payType string) MerchantDeployInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantDeployInfo MerchantDeployInfo
|
||||
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).Filter("pay_type", payType).Limit(1).All(&merchantDeployInfo)
|
||||
if err != nil {
|
||||
logs.Error("get merchant deploy by uid and paytype fail:", err)
|
||||
}
|
||||
return merchantDeployInfo
|
||||
}
|
||||
|
||||
func GetMerchantDeployByUid(uid string) (ms []MerchantDeployInfo) {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).All(&ms)
|
||||
if err != nil {
|
||||
logs.Error("get merchant deploy by uid fail:", err)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
|
||||
func GetMerchantDeployByHour(hour int) []MerchantDeployInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantDeployList []MerchantDeployInfo
|
||||
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("unfreeze_hour", hour).Filter("status", "active").Limit(-1).All(&merchantDeployList)
|
||||
if err != nil {
|
||||
logs.Error("get merchant deploy list fail: ", err)
|
||||
}
|
||||
|
||||
return merchantDeployList
|
||||
}
|
||||
func DeleteMerchantDeployByUidAndPayType(uid, payType string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(MERCHANT_DEPLOY_INFO).Filter("merchant_uid", uid).Filter("pay_type", payType).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete merchant deploy by uid and payType fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdateMerchantDeploy(merchantDeploy MerchantDeployInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&merchantDeploy)
|
||||
if err != nil {
|
||||
logs.Error("update merchant deploy fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetMerchantDeployLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_DEPLOY_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Count()
|
||||
if err != nil {
|
||||
logs.Error("get merchant deploy len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMerchantDeployListByMap(params map[string]string, displayCount, offset int) (md []MerchantDeployInfo) {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_DEPLOY_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&md)
|
||||
if err != nil {
|
||||
logs.Error("get merchant deploy list by map fail: ", err)
|
||||
}
|
||||
return md
|
||||
}
|
@@ -1,205 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/9/28 16:47
|
||||
** @Author : yuebin
|
||||
** @File : merchant_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/9/28 16:47
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type MerchantInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
BelongAgentUid string
|
||||
BelongAgentName string
|
||||
MerchantName string
|
||||
MerchantUid string
|
||||
MerchantKey string
|
||||
MerchantSecret string
|
||||
LoginPassword string
|
||||
LoginAccount string
|
||||
AutoSettle string
|
||||
AutoPayFor string
|
||||
WhiteIps string
|
||||
Remark string
|
||||
SinglePayForRoadUid string
|
||||
SinglePayForRoadName string
|
||||
RollPayForRoadCode string
|
||||
RollPayForRoadName string
|
||||
PayforFee float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const MERCHANT_INFO = "merchant_info"
|
||||
|
||||
func IsExistByMerchantName(merchantName string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("merchant_name", merchantName).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistByMerchantUid(uid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", uid).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistMerchantByAgentUid(uid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("belong_agent_uid", uid).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistByMerchantPhone(phone string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(MERCHANT_INFO).Filter("LoginAccount", phone).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetMerchantByPhone(phone string) (m MerchantInfo) {
|
||||
o := orm.NewOrm()
|
||||
_, e := o.QueryTable(MERCHANT_INFO).Filter("LoginAccount", phone).Limit(1).All(&m)
|
||||
if e != nil {
|
||||
logs.Error("GetMerchantByPhone merchant fail: ", e)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func InsertMerchantInfo(merchantInfo MerchantInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetMerchantLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Count()
|
||||
if err != nil {
|
||||
logs.Error("get merchant len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMerchantListByMap(params map[string]string, displayCount, offset int) []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
var merchantList []MerchantInfo
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&merchantList)
|
||||
if err != nil {
|
||||
logs.Error("get merchant list by map fail: ", err)
|
||||
}
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetAllMerchant() []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantList []MerchantInfo
|
||||
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Limit(-1).All(&merchantList)
|
||||
if err != nil {
|
||||
logs.Error("get all merchant fail:", err)
|
||||
}
|
||||
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetMerchantByParams(params map[string]string, displayCount, offset int) []MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantList []MerchantInfo
|
||||
qs := o.QueryTable(MERCHANT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
qs.Limit(displayCount, offset).All(&merchantList)
|
||||
|
||||
return merchantList
|
||||
}
|
||||
|
||||
func GetMerchantLenByParams(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
cnt, err := qs.Limit(-1).Count()
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get merchant len by params fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetMerchantByUid(merchantUid string) MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantInfo MerchantInfo
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", merchantUid).Limit(1).All(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("get merchant info fail: ", err)
|
||||
}
|
||||
return merchantInfo
|
||||
}
|
||||
|
||||
func GetMerchantByPaykey(payKey string) MerchantInfo {
|
||||
o := orm.NewOrm()
|
||||
var merchantInfo MerchantInfo
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_key", payKey).Limit(1).All(&merchantInfo)
|
||||
if err != nil {
|
||||
logs.Error("get merchant by merchantKey fail: ", err)
|
||||
}
|
||||
return merchantInfo
|
||||
}
|
||||
|
||||
func UpdateMerchant(merchantInfo MerchantInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&merchantInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteMerchantByUid(merchantUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(MERCHANT_INFO).Filter("merchant_uid", merchantUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete merchant fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/22 13:07
|
||||
** @Author : yuebin
|
||||
** @File : merchant_load_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/22 13:07
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type MerchantLoadInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
MerchantUid string
|
||||
RoadUid string
|
||||
LoadDate string
|
||||
LoadAmount float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const MERCHANT_LOAD_INFO = "merchant_load_info"
|
||||
|
||||
func GetMerchantLoadInfoByMap(params map[string]string) []MerchantLoadInfo {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_LOAD_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
var merchantLoadList []MerchantLoadInfo
|
||||
_, err := qs.Limit(-11).All(&merchantLoadList)
|
||||
if err != nil {
|
||||
logs.Error("get merchant load info fail: ", err)
|
||||
}
|
||||
return merchantLoadList
|
||||
}
|
||||
|
||||
func IsExistMerchantLoadByParams(params map[string]string) bool {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(MERCHANT_LOAD_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
return qs.Exist()
|
||||
}
|
@@ -1,103 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/20 13:13
|
||||
** @Author : yuebin
|
||||
** @File : notify_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/20 13:13
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type NotifyInfo struct {
|
||||
Id int
|
||||
Type string //订单-order,代付-payfor
|
||||
BankOrderId string
|
||||
MerchantOrderId string
|
||||
Status string
|
||||
Times int
|
||||
Url string
|
||||
Response string
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const NOTIFYINFO = "notify_info"
|
||||
|
||||
func InsertNotifyInfo(notifyInfo NotifyInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert notify fail:", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func NotifyInfoExistByBankOrderId(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(NOTIFYINFO).Filter("bank_order_id", bankOrderId).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetNotifyInfoByBankOrderId(bankOrderId string) NotifyInfo {
|
||||
o := orm.NewOrm()
|
||||
var notifyInfo NotifyInfo
|
||||
_, err := o.QueryTable(NOTIFYINFO).Filter("bank_order_id", bankOrderId).All(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("get notify info by bankOrderId fail: ", err)
|
||||
}
|
||||
|
||||
return notifyInfo
|
||||
}
|
||||
|
||||
func GetNotifyInfosNotSuccess(params map[string]interface{}) []NotifyInfo {
|
||||
o := orm.NewOrm()
|
||||
var notifyInfoList []NotifyInfo
|
||||
qs := o.QueryTable(NOTIFYINFO)
|
||||
for k, v := range params {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
qs = qs.Exclude("status", "success")
|
||||
_, err := qs.Limit(-1).All(¬ifyInfoList)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get notifyinfos fail: ", err)
|
||||
}
|
||||
|
||||
return notifyInfoList
|
||||
}
|
||||
|
||||
func GetNotifyBankOrderIdListByParams(params map[string]string) []string {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(NOTIFYINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
var notifyList []NotifyInfo
|
||||
qs.Limit(-1).All(¬ifyList)
|
||||
var list []string
|
||||
for _, n := range notifyList {
|
||||
list = append(list, n.BankOrderId)
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
func UpdateNotifyInfo(notifyInfo NotifyInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(¬ifyInfo)
|
||||
if err != nil {
|
||||
logs.Error("update notify info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,222 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/28 10:15
|
||||
** @Author : yuebin
|
||||
** @File : order_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/28 10:15
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type OrderInfo struct {
|
||||
Id int
|
||||
ShopName string //商品名称
|
||||
OrderPeriod string //订单有效时间
|
||||
MerchantOrderId string //商户订单id
|
||||
BankOrderId string //本系统订单id
|
||||
BankTransId string //上游流水id
|
||||
OrderAmount float64 //订单提交的金额
|
||||
ShowAmount float64 //待支付的金额
|
||||
FactAmount float64 //用户实际支付金额
|
||||
RollPoolCode string //轮询池编码
|
||||
RollPoolName string //轮询池名臣
|
||||
RoadUid string //通道标识
|
||||
RoadName string //通道名称
|
||||
PayProductName string //上游支付公司的名称
|
||||
PayProductCode 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 //商户id
|
||||
MerchantName string //商户名称
|
||||
AgentUid string //该商户所属代理
|
||||
AgentName string //该商户所属代理名称
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ORDER_INFO = "order_info"
|
||||
|
||||
func InsertOrder(orderInfo OrderInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&orderInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert order info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func OrderNoIsEixst(orderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exits := o.QueryTable(ORDER_INFO).Filter("merchant_order_id", orderId).Exist()
|
||||
return exits
|
||||
}
|
||||
|
||||
func BankOrderIdIsEixst(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exists := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Exist()
|
||||
return exists
|
||||
}
|
||||
|
||||
func GetOrderLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ORDER_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, _ := qs.Limit(-1).Count()
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetOrderByMap(params map[string]string, display, offset int) []OrderInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderInfoList []OrderInfo
|
||||
qs := o.QueryTable(ORDER_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&orderInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get order by map fail: ", err)
|
||||
}
|
||||
return orderInfoList
|
||||
}
|
||||
|
||||
func GetSuccessRateByMap(params map[string]string) string {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ORDER_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
successRate := "0%"
|
||||
allCount, _ := qs.Limit(-1).Count()
|
||||
successCount, _ := qs.Filter("status", "success").Limit(-1).Count()
|
||||
if allCount == 0 {
|
||||
return successRate
|
||||
}
|
||||
tmp := float64(successCount) / float64(allCount) * 100
|
||||
successRate = fmt.Sprintf("%.1f", tmp)
|
||||
return successRate + "%"
|
||||
}
|
||||
|
||||
func GetAllAmountByMap(params map[string]string) float64 {
|
||||
o := orm.NewOrm()
|
||||
condition := "select sum(order_amount) as allAmount from order_info "
|
||||
for _, v := range params {
|
||||
if len(v) > 0 {
|
||||
condition = condition + "where "
|
||||
break
|
||||
}
|
||||
}
|
||||
flag := false
|
||||
if params["create_time__gte"] != "" {
|
||||
flag = true
|
||||
condition = condition + " create_time >= '" + params["create_time__gte"] + "'"
|
||||
}
|
||||
if params["create_time__lte"] != "" {
|
||||
if flag {
|
||||
condition = condition + " and "
|
||||
}
|
||||
condition = condition + " create_time <= '" + params["create_time__lte"] + "'"
|
||||
}
|
||||
if params["merchant_name__icontains"] != "" {
|
||||
if flag {
|
||||
condition = condition + " and "
|
||||
}
|
||||
condition = condition + "merchant_name like %'" + params["merchant_name__icontains"] + "'% "
|
||||
}
|
||||
if params["merchant_order_id"] != "" {
|
||||
if flag {
|
||||
condition = condition + " and "
|
||||
}
|
||||
condition = condition + " merchant_order_id = '" + params["merchant_order_id"] + "'"
|
||||
}
|
||||
if params["bank_order_id"] != "" {
|
||||
if flag {
|
||||
condition = condition + " and "
|
||||
}
|
||||
condition = condition + " bank_order_id = '" + params["bank_order_id"] + "'"
|
||||
}
|
||||
if params["status"] != "" {
|
||||
if flag {
|
||||
condition = condition + " and "
|
||||
}
|
||||
condition = condition + "status = '" + params["status"] + "'"
|
||||
}
|
||||
if params["pay_product_code"] != "" {
|
||||
if flag {
|
||||
condition = condition + " and "
|
||||
}
|
||||
condition = condition + "pay_product_code = " + params["pay_product_code"] + "'"
|
||||
}
|
||||
if params["pay_type_code"] != "" {
|
||||
if flag {
|
||||
condition = condition + " and "
|
||||
}
|
||||
condition = condition + "pay_type_code = " + params["pay_type_code"]
|
||||
}
|
||||
logs.Info("get order amount str = ", condition)
|
||||
var maps []orm.Params
|
||||
allAmount := 0.00
|
||||
num, err := o.Raw(condition).Values(&maps)
|
||||
if err == nil && num > 0 {
|
||||
allAmount, _ = strconv.ParseFloat(maps[0]["allAmount"].(string), 64)
|
||||
}
|
||||
return allAmount
|
||||
}
|
||||
|
||||
func GetOrderByBankOrderId(bankOrderId string) OrderInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderInfo OrderInfo
|
||||
_, err := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderInfo)
|
||||
if err != nil {
|
||||
logs.Error("get order info by bankOrderId fail: ", err)
|
||||
}
|
||||
return orderInfo
|
||||
}
|
||||
|
||||
func GetOrderByMerchantOrderId(merchantOrderId string) OrderInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderInfo OrderInfo
|
||||
_, err := o.QueryTable(ORDER_INFO).Filter("merchant_order_id", merchantOrderId).Limit(1).All(&orderInfo)
|
||||
if err != nil {
|
||||
logs.Error("get order by merchant_order_id: ", err.Error())
|
||||
}
|
||||
return orderInfo
|
||||
}
|
||||
|
||||
func GetOneOrder(bankOrderId string) OrderInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderInfo OrderInfo
|
||||
_, err := o.QueryTable(ORDER_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderInfo)
|
||||
if err != nil {
|
||||
logs.Error("get one order fail: ", err)
|
||||
}
|
||||
|
||||
return orderInfo
|
||||
}
|
@@ -1,119 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/30 11:44
|
||||
** @Author : yuebin
|
||||
** @File : order_profit_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/30 11:44
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type OrderProfitInfo struct {
|
||||
Id int
|
||||
MerchantName string
|
||||
MerchantUid string
|
||||
AgentName string
|
||||
AgentUid string
|
||||
PayProductCode string
|
||||
PayProductName string
|
||||
PayTypeCode string
|
||||
PayTypeName string
|
||||
Status string
|
||||
MerchantOrderId string
|
||||
BankOrderId string
|
||||
BankTransId string
|
||||
OrderAmount float64
|
||||
ShowAmount float64
|
||||
FactAmount float64
|
||||
UserInAmount float64
|
||||
SupplierRate float64
|
||||
PlatformRate float64
|
||||
AgentRate float64
|
||||
AllProfit float64
|
||||
SupplierProfit float64
|
||||
PlatformProfit float64
|
||||
AgentProfit float64
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ORDER_PROFIT_INFO = "order_profit_info"
|
||||
|
||||
func GetOrderProfitByBankOrderId(bankOrderId string) OrderProfitInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderProfit OrderProfitInfo
|
||||
_, err := o.QueryTable(ORDER_PROFIT_INFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&orderProfit)
|
||||
if err != nil {
|
||||
logs.Error("GetOrderProfitByBankOrderId fail:", err)
|
||||
}
|
||||
return orderProfit
|
||||
}
|
||||
|
||||
func GetOrderProfitLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ORDER_PROFIT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, _ := qs.Limit(-1).Count()
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetOrderProfitByMap(params map[string]string, display, offset int) []OrderProfitInfo {
|
||||
o := orm.NewOrm()
|
||||
var orderProfitInfoList []OrderProfitInfo
|
||||
qs := o.QueryTable(ORDER_PROFIT_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&orderProfitInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get order by map fail: ", err)
|
||||
}
|
||||
return orderProfitInfoList
|
||||
}
|
||||
|
||||
func GetPlatformProfitByMap(params map[string]string) []PlatformProfit {
|
||||
|
||||
o := orm.NewOrm()
|
||||
|
||||
cond := "select merchant_name, agent_name, pay_product_name as supplier_name, pay_type_name, sum(fact_amount) as order_amount, count(1) as order_count, " +
|
||||
"sum(platform_profit) as platform_profit, sum(agent_profit) as agent_profit from " + ORDER_PROFIT_INFO + " where status='success' "
|
||||
flag := false
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
if flag {
|
||||
cond += " and"
|
||||
}
|
||||
if strings.Contains(k, "create_time__gte") {
|
||||
cond = cond + " create_time>='" + v + "'"
|
||||
} else if strings.Contains(k, "create_time__lte") {
|
||||
cond = cond + " create_time<='" + v + "'"
|
||||
} else {
|
||||
cond = cond + " " + k + "='" + v + "'"
|
||||
}
|
||||
flag = true
|
||||
}
|
||||
}
|
||||
|
||||
cond += " group by merchant_uid, agent_uid, pay_product_code, pay_type_code"
|
||||
|
||||
var platformProfitList []PlatformProfit
|
||||
_, err := o.Raw(cond).QueryRows(&platformProfitList)
|
||||
if err != nil {
|
||||
logs.Error("get platform profit by map fail:", err)
|
||||
}
|
||||
|
||||
return platformProfitList
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/30 11:41
|
||||
** @Author : yuebin
|
||||
** @File : order_settle_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/30 11:41
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type OrderSettleInfo struct {
|
||||
Id int
|
||||
PayProductCode string
|
||||
PayProductName string
|
||||
PayTypeCode string
|
||||
RoadUid string
|
||||
PayTypeName string
|
||||
MerchantUid string
|
||||
MerchantName string
|
||||
MerchantOrderId string
|
||||
BankOrderId string
|
||||
SettleAmount float64
|
||||
IsAllowSettle string
|
||||
IsCompleteSettle string
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ORDER_SETTLE_INFO = "order_settle_info"
|
||||
|
||||
func GetOrderSettleListByParams(params map[string]string) []OrderSettleInfo {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ORDER_SETTLE_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
var orderSettleList []OrderSettleInfo
|
||||
if _, err := qs.Limit(-1).All(&orderSettleList); err != nil {
|
||||
logs.Error("get order settle list fail: ", err)
|
||||
}
|
||||
|
||||
return orderSettleList
|
||||
}
|
@@ -1,227 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/11/25 14:32
|
||||
** @Author : yuebin
|
||||
** @File : payfor_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/11/25 14:32
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"gateway/common"
|
||||
"gateway/utils"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type PayforInfo struct {
|
||||
Id int
|
||||
PayforUid string
|
||||
MerchantUid string
|
||||
MerchantName string
|
||||
MerchantOrderId string
|
||||
BankOrderId string
|
||||
BankTransId string
|
||||
RoadUid string
|
||||
RoadName string
|
||||
RollPoolCode string
|
||||
RollPoolName string
|
||||
PayforFee float64
|
||||
PayforAmount float64
|
||||
PayforTotalAmount float64
|
||||
BankCode string
|
||||
BankName string
|
||||
BankAccountName string
|
||||
BankAccountNo string
|
||||
BankAccountType string
|
||||
Country string
|
||||
City string
|
||||
Ares string
|
||||
BankAccountAddress string
|
||||
PhoneNo string
|
||||
GiveType string
|
||||
Type string
|
||||
NotifyUrl string
|
||||
Status string
|
||||
IsSend string
|
||||
RequestTime string
|
||||
ResponseTime string
|
||||
ResponseContext string
|
||||
Remark string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
const PAYFORINFO = "payfor_info"
|
||||
|
||||
func InsertPayfor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&payFor)
|
||||
if err != nil {
|
||||
logs.Error("insert payfor fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func IsExistPayForByBankOrderId(bankOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(PAYFORINFO).Filter("bank_order_id", bankOrderId).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func IsExistPayForByMerchantOrderId(merchantOrderId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(PAYFORINFO).Filter("merchant_order_id", merchantOrderId).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func GetPayForLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
cnt, err := qs.Limit(-1).Count()
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get pay for len by map fail: ", err)
|
||||
}
|
||||
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetPayForByMap(params map[string]string, displayCount, offset int) []PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payForList []PayforInfo
|
||||
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-create_time").All(&payForList)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get agentInfo by map fail: ", err)
|
||||
}
|
||||
|
||||
return payForList
|
||||
}
|
||||
|
||||
func GetPayForListByParams(params map[string]string) []PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payForList []PayforInfo
|
||||
qs := o.QueryTable(PAYFORINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(-1).All(&payForList)
|
||||
if err != nil {
|
||||
logs.Error("GetPayForListByParams fail:", err)
|
||||
}
|
||||
return payForList
|
||||
}
|
||||
|
||||
func GetPayForByBankOrderId(bankOrderId string) PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payFor PayforInfo
|
||||
_, err := o.QueryTable(PAYFORINFO).Filter("bank_order_id", bankOrderId).Limit(1).All(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get pay for by bank_order_id fail: ", err)
|
||||
}
|
||||
|
||||
return payFor
|
||||
}
|
||||
|
||||
func GetPayForByMerchantOrderId(merchantOrderId string) PayforInfo {
|
||||
o := orm.NewOrm()
|
||||
var payFor PayforInfo
|
||||
|
||||
_, err := o.QueryTable(PAYFORINFO).Filter("merchant_order_id", merchantOrderId).Limit(1).All(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("fail: ", err)
|
||||
}
|
||||
|
||||
return payFor
|
||||
}
|
||||
|
||||
func ForUpdatePayFor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
var tmp PayforInfo
|
||||
if err := txOrm.Raw("select * from payfor_info where bank_order_id = ? for update", payFor.BankOrderId).QueryRow(&tmp); err != nil || tmp.PayforUid == "" {
|
||||
logs.Error("for update payfor select fail:", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if tmp.Status == common.PAYFOR_FAIL || tmp.Status == common.PAYFOR_SUCCESS {
|
||||
return errors.New("订单已经处理")
|
||||
}
|
||||
|
||||
//如果是手动打款,并且是需要处理商户金额
|
||||
if payFor.Status == common.PAYFOR_SOLVING && tmp.Status == common.PAYFOR_COMFRIM &&
|
||||
payFor.GiveType == common.PAYFOR_HAND && payFor.Type != common.SELF_HELP {
|
||||
|
||||
var account AccountInfo
|
||||
if err := txOrm.Raw("select * from account_info where account_uid = ? for update", payFor.MerchantUid).QueryRow(&account); err != nil || account.AccountUid == "" {
|
||||
logs.Error("for update payfor select account info,fail:", err)
|
||||
return err
|
||||
}
|
||||
//计算该用户的可用金额
|
||||
ableAmount := account.SettleAmount - account.FreezeAmount - account.PayforAmount - account.LoanAmount
|
||||
if ableAmount >= payFor.PayforAmount+payFor.PayforFee {
|
||||
account.PayforAmount += payFor.PayforFee + payFor.PayforAmount
|
||||
account.UpdateTime = utils.GetBasicDateTime()
|
||||
if _, err := txOrm.Update(&account); err != nil {
|
||||
logs.Error("for update payfor update account fail:", err)
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,可用金额不够", payFor.MerchantUid))
|
||||
payFor.ResponseContext = "商户可用余额不足"
|
||||
payFor.Status = common.PAYFOR_FAIL
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := txOrm.Update(&payFor); err != nil {
|
||||
logs.Error("for update payfor fail: ", err)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdatePayFor(payFor PayforInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&payFor)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update pay for fail:", err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/12/17 17:50
|
||||
** @Author : yuebin
|
||||
** @File : platform_profit
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/12/17 17:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
type PlatformProfit struct {
|
||||
MerchantName string
|
||||
AgentName string
|
||||
SupplierName string
|
||||
PayTypeName string
|
||||
OrderAmount float64
|
||||
OrderCount int
|
||||
PlatformProfit float64
|
||||
AgentProfit float64
|
||||
}
|
@@ -1,143 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/28 17:59
|
||||
** @Author : yuebin
|
||||
** @File : power_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/28 17:59
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type PowerInfo struct {
|
||||
Id int
|
||||
FirstMenuUid string
|
||||
SecondMenuUid string
|
||||
SecondMenu string
|
||||
PowerId string
|
||||
PowerItem string
|
||||
Creater string
|
||||
Status string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
const POWER_INFO = "power_info"
|
||||
|
||||
type PowerInfoSlice []PowerInfo
|
||||
|
||||
func (sm PowerInfoSlice) Len() int {
|
||||
return len(sm)
|
||||
}
|
||||
|
||||
func (sm PowerInfoSlice) Swap(i, j int) {
|
||||
sm[i], sm[j] = sm[j], sm[i]
|
||||
}
|
||||
|
||||
func (sm PowerInfoSlice) Less(i, j int) bool {
|
||||
return sm[i].SecondMenuUid < sm[j].SecondMenuUid
|
||||
}
|
||||
|
||||
func PowerUidExists(powerUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exists := o.QueryTable(POWER_INFO).Filter("power_id", powerUid).Exist()
|
||||
return exists
|
||||
}
|
||||
|
||||
func InsertPowerInfo(powerInfo PowerInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&powerInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert power info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetPower() []PowerInfo {
|
||||
o := orm.NewOrm()
|
||||
var powerInfo []PowerInfo
|
||||
_, err := o.QueryTable(POWER_INFO).Limit(-1).All(&powerInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get power fail: ", err)
|
||||
}
|
||||
return powerInfo
|
||||
}
|
||||
|
||||
func GetPowerById(powerId string) PowerInfo {
|
||||
o := orm.NewOrm()
|
||||
var powerInfo PowerInfo
|
||||
_, err := o.QueryTable(POWER_INFO).Filter("power_id", powerId).Limit(1).All(&powerInfo)
|
||||
if err != nil {
|
||||
logs.Error("get power by id fail: ", err)
|
||||
}
|
||||
return powerInfo
|
||||
}
|
||||
|
||||
func GetPowerByIds(powerIds []string) []PowerInfo {
|
||||
var powerInfoList []PowerInfo
|
||||
for _, v := range powerIds {
|
||||
m := GetPowerById(v)
|
||||
powerInfoList = append(powerInfoList, m)
|
||||
}
|
||||
return powerInfoList
|
||||
}
|
||||
|
||||
func GetPowerItemLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(POWER_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Limit(-1).Count()
|
||||
if err != nil {
|
||||
logs.Error("get power item len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetPowerItemByMap(params map[string]string, displpay, offset int) []PowerInfo {
|
||||
o := orm.NewOrm()
|
||||
var powerItemList []PowerInfo
|
||||
qs := o.QueryTable(POWER_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := qs.Limit(displpay, offset).OrderBy("-update_time").All(&powerItemList)
|
||||
if err != nil {
|
||||
logs.Error("get power item by map fail: ", err)
|
||||
}
|
||||
return powerItemList
|
||||
}
|
||||
|
||||
func DeletePowerItemByPowerID(powerID string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(POWER_INFO).Filter("power_id", powerID).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete power item by powerID fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func DeletePowerBySecondUid(secondUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(POWER_INFO).Filter("second_menu_uid", secondUid).Delete()
|
||||
|
||||
if err != nil {
|
||||
logs.Error("delete power by second menu uid fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,162 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/9/8 12:09
|
||||
** @Author : yuebin
|
||||
** @File : road_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/9/8 12:09
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type RoadInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
RoadName string
|
||||
RoadUid string
|
||||
Remark string
|
||||
ProductName string
|
||||
ProductUid string
|
||||
PayType string
|
||||
BasicFee float64
|
||||
SettleFee float64
|
||||
TotalLimit float64
|
||||
TodayLimit float64
|
||||
SingleMinLimit float64
|
||||
SingleMaxLimit float64
|
||||
StarHour int
|
||||
EndHour int
|
||||
Params string
|
||||
TodayIncome float64
|
||||
TotalIncome float64
|
||||
TodayProfit float64
|
||||
TotalProfit float64
|
||||
Balance float64
|
||||
RequestAll int
|
||||
RequestSuccess int
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ROAD_INFO = "road_info"
|
||||
|
||||
func GetRoadInfoByRoadUid(roadUid string) RoadInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadInfo RoadInfo
|
||||
_, err := o.QueryTable(ROAD_INFO).Exclude("status", "delete").Filter("road_uid", roadUid).Limit(1).All(&roadInfo)
|
||||
if err != nil {
|
||||
logs.Error("get road info by road uid fail: ", err)
|
||||
}
|
||||
return roadInfo
|
||||
}
|
||||
|
||||
func GetRoadInfosByRoadUids(roadUids []string) []RoadInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadInfoList []RoadInfo
|
||||
_, err := o.QueryTable(ROAD_INFO).Filter("road_uid__in", roadUids).OrderBy("update_time").All(&roadInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get roadInfos by roadUids fail: ", err)
|
||||
}
|
||||
return roadInfoList
|
||||
}
|
||||
|
||||
func GetRoadInfoByName(roadName string) RoadInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadInfo RoadInfo
|
||||
_, err := o.QueryTable(ROAD_INFO).Exclude("status", "delete").Filter("road_name", roadName).Limit(1).All(&roadInfo)
|
||||
if err != nil {
|
||||
logs.Error("get road info by name fail: ", err)
|
||||
}
|
||||
return roadInfo
|
||||
}
|
||||
|
||||
func GetRoadLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ROAD_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Exclude("status", "delete").Limit(-1).Count()
|
||||
if err != nil {
|
||||
logs.Error("get road len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetRoadInfoByMap(params map[string]string, displayCount, offset int) []RoadInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadInfoList []RoadInfo
|
||||
qs := o.QueryTable(ROAD_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
_, err := qs.Exclude("status", "delete").Limit(displayCount, offset).OrderBy("-update_time").All(&roadInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get road info by map fail: ", err)
|
||||
}
|
||||
return roadInfoList
|
||||
}
|
||||
|
||||
func GetAllRoad(params map[string]string) []RoadInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadInfoList []RoadInfo
|
||||
qs := o.QueryTable(ROAD_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(-1).All(&roadInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get all road fail: ", err)
|
||||
}
|
||||
return roadInfoList
|
||||
}
|
||||
|
||||
func InsertRoadInfo(roadInfo RoadInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&roadInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("insert road info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func RoadInfoExistByRoadUid(roadUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(ROAD_INFO).Filter("status", "active").Filter("road_uid", roadUid).Exist()
|
||||
|
||||
return exist
|
||||
}
|
||||
|
||||
func UpdateRoadInfo(roadInfo RoadInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&roadInfo)
|
||||
if err != nil {
|
||||
logs.Error("update road info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteRoadByRoadUid(roadUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(ROAD_INFO).Filter("road_uid", roadUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete road by road uid fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,127 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/9/9 16:35
|
||||
** @Author : yuebin
|
||||
** @File : road_pool_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/9/9 16:35
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type RoadPoolInfo struct {
|
||||
Id int
|
||||
Status string
|
||||
RoadPoolName string
|
||||
RoadPoolCode string
|
||||
RoadUidPool string
|
||||
UpdateTime string
|
||||
CreateTime string
|
||||
}
|
||||
|
||||
const ROAD_POOL_INFO = "road_pool_info"
|
||||
|
||||
func InsertRoadPool(roadPool RoadPoolInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&roadPool)
|
||||
if err != nil {
|
||||
logs.Error("insert road pool fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func GetRoadPoolLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ROAD_POOL_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Limit(-1).Count()
|
||||
if err != nil {
|
||||
logs.Error("get road pool len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetRoadPoolByMap(params map[string]string, displayCount, offset int) []RoadPoolInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadPoolList []RoadPoolInfo
|
||||
qs := o.QueryTable(ROAD_POOL_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&roadPoolList)
|
||||
if err != nil {
|
||||
logs.Error("get road pool by map fail: ", err)
|
||||
}
|
||||
return roadPoolList
|
||||
}
|
||||
|
||||
func GetRoadPoolByRoadPoolCode(roadPoolCode string) RoadPoolInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadPoolInfo RoadPoolInfo
|
||||
_, err := o.QueryTable(ROAD_POOL_INFO).Filter("road_pool_code", roadPoolCode).Limit(1).All(&roadPoolInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get road pool info by road pool code fail: ", err)
|
||||
}
|
||||
|
||||
return roadPoolInfo
|
||||
}
|
||||
|
||||
func GetAllRollPool(params map[string]string) []RoadPoolInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadPoolList []RoadPoolInfo
|
||||
qs := o.QueryTable(ROAD_POOL_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(-1).All(&roadPoolList)
|
||||
if err != nil {
|
||||
logs.Error("get all roll pool fail: ", err)
|
||||
}
|
||||
return roadPoolList
|
||||
}
|
||||
|
||||
func GetRoadPoolByName(roadPoolName string) RoadPoolInfo {
|
||||
o := orm.NewOrm()
|
||||
var roadPoolInfo RoadPoolInfo
|
||||
_, err := o.QueryTable(ROAD_POOL_INFO).Filter("road_pool_name", roadPoolName).Limit(1).All(&roadPoolInfo)
|
||||
if err != nil {
|
||||
logs.Error("get road pool by name fail: ", err)
|
||||
}
|
||||
return roadPoolInfo
|
||||
}
|
||||
|
||||
func DeleteRoadPoolByCode(roadPoolCode string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(ROAD_POOL_INFO).Filter("road_pool_code", roadPoolCode).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete road pool by code fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdateRoadPool(roadPool RoadPoolInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&roadPool)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update road pool fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,123 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/29 14:43
|
||||
** @Author : yuebin
|
||||
** @File : role_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/29 14:43
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
type RoleInfo struct {
|
||||
Id int
|
||||
RoleName string
|
||||
RoleUid string
|
||||
ShowFirstMenu string
|
||||
ShowFirstUid string
|
||||
ShowSecondMenu string
|
||||
ShowSecondUid string
|
||||
ShowPower string
|
||||
ShowPowerUid string
|
||||
Creater string
|
||||
Status string
|
||||
Remark string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
const ROLE_INFO = "role_info"
|
||||
|
||||
func GetRoleLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(ROLE_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
cnt, err := qs.Count()
|
||||
if err != nil {
|
||||
logs.Error("get role len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetRole() []RoleInfo {
|
||||
o := orm.NewOrm()
|
||||
var roleInfo []RoleInfo
|
||||
_, err := o.QueryTable(ROLE_INFO).Limit(-1).OrderBy("-update_time").All(&roleInfo)
|
||||
if err != nil {
|
||||
logs.Error("get all role fail: ", err)
|
||||
}
|
||||
return roleInfo
|
||||
}
|
||||
|
||||
func GetRoleByMap(params map[string]string, display, offset int) []RoleInfo {
|
||||
o := orm.NewOrm()
|
||||
var roleInfo []RoleInfo
|
||||
qs := o.QueryTable(ROLE_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&roleInfo)
|
||||
if err != nil {
|
||||
logs.Error("get role by map fail: ", err)
|
||||
}
|
||||
return roleInfo
|
||||
}
|
||||
|
||||
func GetRoleByRoleUid(roleUid string) RoleInfo {
|
||||
o := orm.NewOrm()
|
||||
var roleInfo RoleInfo
|
||||
_, err := o.QueryTable(ROLE_INFO).Filter("role_uid", roleUid).Limit(1).All(&roleInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get role by role uid fail: ", err)
|
||||
}
|
||||
return roleInfo
|
||||
}
|
||||
|
||||
func RoleNameExists(roleName string) bool {
|
||||
o := orm.NewOrm()
|
||||
exists := o.QueryTable(ROLE_INFO).Filter("role_name", roleName).Exist()
|
||||
return exists
|
||||
}
|
||||
|
||||
func InsertRole(roleInfo RoleInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&roleInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert role fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteRoleByRoleUid(roleUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(ROLE_INFO).Filter("role_uid", roleUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete role by role uid fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdateRoleInfo(roleInfo RoleInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&roleInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update role info fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
@@ -1,216 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/26 9:33
|
||||
** @Author : yuebin
|
||||
** @File : second_menu_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/26 9:33
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
const SECOND_MENU_INFO = "second_menu_info"
|
||||
|
||||
type SecondMenuInfo struct {
|
||||
Id int
|
||||
FirstMenuOrder int
|
||||
FirstMenuUid string
|
||||
FirstMenu string
|
||||
MenuOrder int
|
||||
SecondMenuUid string
|
||||
SecondMenu string
|
||||
SecondRouter string
|
||||
Creater string
|
||||
Status string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
type SecondMenuSlice []SecondMenuInfo
|
||||
|
||||
func (sm SecondMenuSlice) Len() int {
|
||||
return len(sm)
|
||||
}
|
||||
|
||||
func (sm SecondMenuSlice) Swap(i, j int) {
|
||||
sm[i], sm[j] = sm[j], sm[i]
|
||||
}
|
||||
|
||||
func (sm SecondMenuSlice) Less(i, j int) bool {
|
||||
if sm[i].FirstMenuOrder == sm[j].FirstMenuOrder {
|
||||
return sm[i].MenuOrder < sm[j].MenuOrder
|
||||
}
|
||||
return sm[i].FirstMenuOrder < sm[j].FirstMenuOrder
|
||||
}
|
||||
|
||||
func GetSecondMenuLen() int {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.QueryTable(SECOND_MENU_INFO).Count()
|
||||
if err != nil {
|
||||
logs.Error("get second meun len fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetSecondMenuInfoByMenuOrder(menuOrder int, firstMenuUid string) SecondMenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var secondMenuInfo SecondMenuInfo
|
||||
_, err := o.QueryTable(SECOND_MENU_INFO).Filter("first_menu_uid", firstMenuUid).Filter("menu_order", menuOrder).Limit(1).All(&secondMenuInfo)
|
||||
if err != nil {
|
||||
logs.Error("get second menu info by menu order fail: ", err)
|
||||
}
|
||||
return secondMenuInfo
|
||||
}
|
||||
|
||||
func GetSecondMenuLenByFirstMenuUid(firstMenuUid string) int {
|
||||
o := orm.NewOrm()
|
||||
cnt, err := o.QueryTable(SECOND_MENU_INFO).Filter("first_menu_uid", firstMenuUid).Count()
|
||||
if err != nil {
|
||||
logs.Error("get second menu len by first menu uid fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetSecondMenuList() []SecondMenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var secondMenuList []SecondMenuInfo
|
||||
_, err := o.QueryTable(SECOND_MENU_INFO).Limit(-1).OrderBy("-update_time").All(&secondMenuList)
|
||||
if err != nil {
|
||||
logs.Error("get second menu list fail: ", err)
|
||||
}
|
||||
return secondMenuList
|
||||
}
|
||||
|
||||
func GetSecondMenuInfoBySecondMenuUid(secondMenuUid string) SecondMenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var secondMenuInfo SecondMenuInfo
|
||||
_, err := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu_uid", secondMenuUid).Limit(1).All(&secondMenuInfo)
|
||||
if err != nil {
|
||||
logs.Error("get scond menu info by second menu uid fail: ", err)
|
||||
}
|
||||
return secondMenuInfo
|
||||
}
|
||||
|
||||
func GetSecondMenuInfoBySecondMenuUids(secondMenuUids []string) []SecondMenuInfo {
|
||||
secondMenuInfoList := make([]SecondMenuInfo, 0)
|
||||
for _, v := range secondMenuUids {
|
||||
sm := GetSecondMenuInfoBySecondMenuUid(v)
|
||||
secondMenuInfoList = append(secondMenuInfoList, sm)
|
||||
}
|
||||
return secondMenuInfoList
|
||||
}
|
||||
|
||||
func GetSecondMenuListByFirstMenuUid(firstMenuUid string) []SecondMenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var secondMenuList []SecondMenuInfo
|
||||
_, err := o.QueryTable(SECOND_MENU_INFO).Filter("first_menu_uid", firstMenuUid).Limit(-1).OrderBy("-update_time").All(&secondMenuList)
|
||||
if err != nil {
|
||||
logs.Error("get second menu list by first menu uid fail: ", err)
|
||||
}
|
||||
return secondMenuList
|
||||
}
|
||||
|
||||
func GetSecondMenuLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(SECOND_MENU_INFO)
|
||||
for k, v := range params {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
cnt, err := qs.Limit(-1).Count()
|
||||
if err != nil {
|
||||
logs.Error("get second menu len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func GetSecondMenuByMap(params map[string]string, displayCount, offset int) []SecondMenuInfo {
|
||||
o := orm.NewOrm()
|
||||
var secondMenuList []SecondMenuInfo
|
||||
qs := o.QueryTable(SECOND_MENU_INFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(displayCount, offset).OrderBy("-update_time").All(&secondMenuList)
|
||||
if err != nil {
|
||||
logs.Error("get second menu by map fail: ", err)
|
||||
}
|
||||
return secondMenuList
|
||||
}
|
||||
func InsertSecondMenu(secondMenuInfo SecondMenuInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&secondMenuInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert second menu fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func SecondMenuIsExists(seconfMenu string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu", seconfMenu).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func SecondMenuUidIsExists(secondMenuUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu_uid", secondMenuUid).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func SecondRouterExists(secondRouter string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(SECOND_MENU_INFO).Filter("second_router", secondRouter).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func DeleteSecondMenuByFirstMenuUid(firstMenuUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
num, err := o.QueryTable(SECOND_MENU_INFO).Filter("first_menu_uid", firstMenuUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete second menu by first menu uid fail: ", err)
|
||||
return false
|
||||
}
|
||||
logs.Info("delete second menu by first menu uid success, num: ", num)
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteSecondMenuBySecondMenuUid(secondMenuUid string) bool {
|
||||
o := orm.NewOrm()
|
||||
num, err := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu_uid", secondMenuUid).Delete()
|
||||
if err != nil {
|
||||
logs.Error("delete second menu by second menu uid fail: ", err)
|
||||
return false
|
||||
}
|
||||
logs.Info("delete second menu by second menu uid success, num: ", num)
|
||||
return true
|
||||
}
|
||||
|
||||
func UpdateSecondMenuOrderBySecondUid(secondUid string, order int) {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(SECOND_MENU_INFO).Filter("second_menu_uid", secondUid).Update(orm.Params{"menu_order": order})
|
||||
if err != nil {
|
||||
logs.Error("update second menu order by second menu uid fail: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateSecondMenu(secondMenu SecondMenuInfo) {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Update(&secondMenu)
|
||||
if err != nil {
|
||||
logs.Error("update second menu for first order fail: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func SecondMenuExistByMenuOrder(menuOrder int) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(SECOND_MENU_INFO).Filter("menu_order", menuOrder).Exist()
|
||||
return exist
|
||||
}
|
@@ -1,87 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/10/19 14:17
|
||||
** @Author : yuebin
|
||||
** @File : transaction
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/10/19 14:17
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
)
|
||||
|
||||
/*func OperatorAccount(accountUid, operatorType string, amount float64) (string, bool) {
|
||||
o := orm.NewOrm()
|
||||
o.Begin()
|
||||
|
||||
defer func(interface{}) {
|
||||
if r := recover(); r != nil {
|
||||
o.Rollback()
|
||||
logs.Error("operator account fail")
|
||||
}
|
||||
}(o)
|
||||
|
||||
msg := ""
|
||||
//处理事务
|
||||
accountInfo := new(AccountInfo)
|
||||
if err := o.Raw("select * from account_info where account_uid = ? for update", accountUid).QueryRow(accountInfo); err != nil || accountInfo.AccountUid == "" {
|
||||
logs.Error("operator account get account info for update fail: ", err)
|
||||
o.Rollback()
|
||||
return msg, false
|
||||
}
|
||||
|
||||
accountInfo.UpdateTime = utils.GetBasicDateTime()
|
||||
flag := true
|
||||
|
||||
switch operatorType {
|
||||
case common.PLUS_AMOUNT: //处理加款操作
|
||||
accountInfo.Balance = accountInfo.Balance + amount
|
||||
accountInfo.SettleAmount = accountInfo.SettleAmount + amount
|
||||
case common.SUB_AMOUNT: //处理减款
|
||||
if accountInfo.Balance >= amount && accountInfo.SettleAmount >= amount {
|
||||
accountInfo.Balance = accountInfo.Balance - amount
|
||||
accountInfo.SettleAmount = accountInfo.SettleAmount - amount
|
||||
} else {
|
||||
msg = "账户余额不够减"
|
||||
flag = false
|
||||
}
|
||||
case common.FREEZE_AMOUNT: //处理冻结款
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount + amount
|
||||
case common.UNFREEZE_AMOUNT: //处理解冻款
|
||||
if accountInfo.FreezeAmount >= amount {
|
||||
accountInfo.FreezeAmount = accountInfo.FreezeAmount - amount
|
||||
} else {
|
||||
msg = "账户冻结金额不够解冻款"
|
||||
flag = false
|
||||
}
|
||||
}
|
||||
if !flag {
|
||||
o.Rollback()
|
||||
return msg, false
|
||||
}
|
||||
|
||||
if _, err := o.Update(accountInfo); err != nil {
|
||||
logs.Error("operator account update account fail: ", err)
|
||||
o.Rollback()
|
||||
return msg, false
|
||||
}
|
||||
//往account_history表中插入一条动账记录
|
||||
accountHistory := AccountHistoryInfo{AccountUid: accountUid, AccountName: accountInfo.AccountName, Type: operatorType,
|
||||
Amount: amount, Balance: accountInfo.Balance, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if _, err := o.Insert(&accountHistory); err != nil {
|
||||
logs.Error("operator account insert account history fail: ", err)
|
||||
o.Rollback()
|
||||
return msg, false
|
||||
}
|
||||
if err := o.Commit(); err != nil {
|
||||
logs.Error("operator account commit fail: ", err)
|
||||
return msg, false
|
||||
} else {
|
||||
logs.Info("操作账户成功")
|
||||
return "", true
|
||||
}
|
||||
}
|
||||
*/
|
@@ -1,146 +0,0 @@
|
||||
/***************************************************
|
||||
** @Desc : This file for ...
|
||||
** @Time : 2019/8/9 14:02
|
||||
** @Author : yuebin
|
||||
** @File : user_info
|
||||
** @Last Modified by : yuebin
|
||||
** @Last Modified time: 2019/8/9 14:02
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
)
|
||||
|
||||
const (
|
||||
USERINFO = "user_info"
|
||||
)
|
||||
|
||||
type UserInfo struct {
|
||||
Id int
|
||||
UserId string
|
||||
Passwd string
|
||||
Nick string
|
||||
Remark string
|
||||
Ip string
|
||||
Status string
|
||||
Role string
|
||||
RoleName string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
}
|
||||
|
||||
func GetUserInfoByUserID(userID string) UserInfo {
|
||||
o := orm.NewOrm()
|
||||
var userInfo UserInfo
|
||||
err := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userID).One(&userInfo)
|
||||
if err != nil {
|
||||
logs.Error("get user info fail: ", err)
|
||||
}
|
||||
return userInfo
|
||||
}
|
||||
|
||||
func GetOperatorByMap(params map[string]string, displayCount, offset int) []UserInfo {
|
||||
o := orm.NewOrm()
|
||||
var userInfo []UserInfo
|
||||
qs := o.QueryTable(USERINFO)
|
||||
for k, v := range params {
|
||||
if len(v) > 0 {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Exclude("status", "delete").Limit(displayCount, offset).OrderBy("-update_time").All(&userInfo)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("get operator by map fail: ", err)
|
||||
}
|
||||
return userInfo
|
||||
}
|
||||
|
||||
func GetOperatorLenByMap(params map[string]string) int {
|
||||
o := orm.NewOrm()
|
||||
qs := o.QueryTable(USERINFO)
|
||||
for k, v := range params {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
cnt, err := qs.Exclude("status", "delete").Count()
|
||||
if err != nil {
|
||||
logs.Error("get operator len by map fail: ", err)
|
||||
}
|
||||
return int(cnt)
|
||||
}
|
||||
|
||||
func UpdateUserInfoIP(userInfo UserInfo) {
|
||||
o := orm.NewOrm()
|
||||
num, err := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userInfo.UserId).Update(orm.Params{"ip": userInfo.Ip})
|
||||
if err != nil {
|
||||
logs.Error("%s update user info ip fail: %v", userInfo.UserId, err)
|
||||
} else {
|
||||
logs.Info("%s update user info ip success, num: %d", userInfo.UserId, num)
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateUserInfoPassword(userInfo UserInfo) {
|
||||
o := orm.NewOrm()
|
||||
num, err := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userInfo.UserId).Update(orm.Params{"passwd": userInfo.Passwd})
|
||||
if err != nil {
|
||||
logs.Error("%s update user info password fail: %v", userInfo.UserId, err)
|
||||
} else {
|
||||
logs.Info("%s update user info password success, update num: %d", userInfo.UserId, num)
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateUserInfo(userInfo UserInfo) {
|
||||
o := orm.NewOrm()
|
||||
if num, err := o.Update(&userInfo); err != nil {
|
||||
logs.Error("update user info fail: ", err)
|
||||
} else {
|
||||
logs.Info("update user info success, num: ", num)
|
||||
}
|
||||
}
|
||||
|
||||
func UpdateStauts(status, userId string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(USERINFO).Filter("user_id", userId).Update(orm.Params{"status": status})
|
||||
|
||||
if err != nil {
|
||||
logs.Error("update status fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func UserInfoExistByUserId(userId string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userId).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func NickIsExist(nick string) bool {
|
||||
o := orm.NewOrm()
|
||||
exist := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("nick", nick).Exist()
|
||||
return exist
|
||||
}
|
||||
|
||||
func InsertUser(userInfo UserInfo) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.Insert(&userInfo)
|
||||
if err != nil {
|
||||
logs.Error("insert user fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func DeleteUserByUserId(userId string) bool {
|
||||
o := orm.NewOrm()
|
||||
_, err := o.QueryTable(USERINFO).Exclude("status", "delete").Filter("user_id", userId).Update(orm.Params{"status": "delete"})
|
||||
|
||||
if err != nil {
|
||||
logs.Error("delete user by userId fail: ", err)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
Reference in New Issue
Block a user