mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-09-16 09:53:48 +08:00
重构了boss系统,添加了逻辑
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/16 11:11
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/19 14:56
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package accounts
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@@ -27,16 +27,6 @@ type AccountHistoryInfo struct {
|
||||
|
||||
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)
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/19 14:41
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package agent
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@@ -72,18 +72,6 @@ func GetAgentInfoByAgentUid(agentUid string) AgentInfo {
|
||||
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)
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/12/17 17:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package agent
|
||||
|
||||
type AgentProfit struct {
|
||||
}
|
@@ -11,6 +11,15 @@ package models
|
||||
|
||||
import (
|
||||
"boss/conf"
|
||||
"boss/models/accounts"
|
||||
"boss/models/agent"
|
||||
"boss/models/merchant"
|
||||
"boss/models/notify"
|
||||
"boss/models/order"
|
||||
"boss/models/payfor"
|
||||
"boss/models/road"
|
||||
"boss/models/system"
|
||||
"boss/models/user"
|
||||
"fmt"
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
@@ -30,10 +39,10 @@ func init() {
|
||||
|
||||
orm.RegisterDriver("mysql", orm.DRMySQL)
|
||||
orm.RegisterDataBase("default", "mysql", link)
|
||||
orm.RegisterModel(new(UserInfo), new(MenuInfo), new(SecondMenuInfo),
|
||||
new(PowerInfo), new(RoleInfo), new(BankCardInfo), new(RoadInfo),
|
||||
new(RoadPoolInfo), new(AgentInfo), new(MerchantInfo), new(MerchantDeployInfo),
|
||||
new(AccountInfo), new(AccountHistoryInfo), new(OrderInfo), new(OrderProfitInfo),
|
||||
new(OrderSettleInfo), new(NotifyInfo), new(MerchantLoadInfo),
|
||||
new(PayforInfo))
|
||||
orm.RegisterModel(new(user.UserInfo), new(system.MenuInfo), new(system.SecondMenuInfo),
|
||||
new(system.PowerInfo), new(system.RoleInfo), new(system.BankCardInfo), new(road.RoadInfo),
|
||||
new(road.RoadPoolInfo), new(agent.AgentInfo), new(merchant.MerchantInfo), new(merchant.MerchantDeployInfo),
|
||||
new(accounts.AccountInfo), new(accounts.AccountHistoryInfo), new(order.OrderInfo), new(order.OrderProfitInfo),
|
||||
new(order.OrderSettleInfo), new(notify.NotifyInfo), new(merchant.MerchantLoadInfo),
|
||||
new(payfor.PayforInfo))
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/7 11:52
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@@ -65,25 +65,6 @@ func GetMerchantDeployByUidAndPayType(uid, payType string) MerchantDeployInfo {
|
||||
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()
|
||||
@@ -103,33 +84,3 @@ func UpdateMerchantDeploy(merchantDeploy MerchantDeployInfo) bool {
|
||||
}
|
||||
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
|
||||
}
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/28 16:47
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@@ -68,15 +68,6 @@ func IsExistByMerchantPhone(phone string) bool {
|
||||
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)
|
||||
@@ -172,16 +163,6 @@ func GetMerchantByUid(merchantUid string) MerchantInfo {
|
||||
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)
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/11/22 13:07
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package merchant
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/11/20 13:13
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package notify
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@@ -39,12 +39,6 @@ func InsertNotifyInfo(notifyInfo NotifyInfo) bool {
|
||||
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
|
||||
@@ -56,23 +50,6 @@ func GetNotifyInfoByBankOrderId(bankOrderId string) NotifyInfo {
|
||||
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)
|
||||
@@ -91,13 +68,3 @@ func GetNotifyBankOrderIdListByParams(params map[string]string) []string {
|
||||
|
||||
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
|
||||
}
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/28 10:15
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package order
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -54,22 +54,6 @@ type OrderInfo struct {
|
||||
|
||||
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()
|
||||
@@ -97,7 +81,7 @@ func GetOrderByMap(params map[string]string, display, offset int) []OrderInfo {
|
||||
qs = qs.Filter(k, v)
|
||||
}
|
||||
}
|
||||
_, err := qs.Limit(display, offset).OrderBy("-update_time").All(&orderInfoList)
|
||||
_, err := qs.Limit(display, offset).OrderBy("-create_time").All(&orderInfoList)
|
||||
if err != nil {
|
||||
logs.Error("get order by map fail: ", err)
|
||||
}
|
||||
@@ -200,16 +184,6 @@ func GetOrderByBankOrderId(bankOrderId string) OrderInfo {
|
||||
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
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/30 11:44
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package order
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/10/30 11:41
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package order
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/12/17 17:50
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package order
|
||||
|
||||
type PlatformProfit struct {
|
||||
MerchantName string
|
@@ -7,10 +7,11 @@
|
||||
** @Last Modified time: 2019/11/25 14:32
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package payfor
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models/accounts"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
@@ -51,7 +52,7 @@ type PayforInfo struct {
|
||||
IsSend string
|
||||
RequestTime string
|
||||
ResponseTime string
|
||||
ResponseContext string
|
||||
ResponseContent string
|
||||
Remark string
|
||||
CreateTime string
|
||||
UpdateTime string
|
||||
@@ -69,20 +70,6 @@ func InsertPayfor(payFor PayforInfo) bool {
|
||||
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)
|
||||
@@ -149,19 +136,6 @@ func GetPayForByBankOrderId(bankOrderId string) PayforInfo {
|
||||
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()
|
||||
|
||||
@@ -181,7 +155,7 @@ func ForUpdatePayFor(payFor PayforInfo) bool {
|
||||
if payFor.Status == common.PAYFOR_SOLVING && tmp.Status == common.PAYFOR_COMFRIM &&
|
||||
payFor.GiveType == common.PAYFOR_HAND && payFor.Type != common.SELF_HELP {
|
||||
|
||||
var account AccountInfo
|
||||
var account accounts.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
|
||||
@@ -197,7 +171,7 @@ func ForUpdatePayFor(payFor PayforInfo) bool {
|
||||
}
|
||||
} else {
|
||||
logs.Error(fmt.Sprintf("商户uid=%s,可用金额不够", payFor.MerchantUid))
|
||||
payFor.ResponseContext = "商户可用余额不足"
|
||||
payFor.ResponseContent = "商户可用余额不足"
|
||||
payFor.Status = common.PAYFOR_FAIL
|
||||
}
|
||||
}
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/8 12:09
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package road
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/9 16:35
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package road
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/9/6 10:19
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/21 9:33
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@@ -119,16 +119,6 @@ func GetMenuAll() []MenuInfo {
|
||||
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
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/28 17:59
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/29 14:43
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/26 9:33
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
||||
@@ -48,15 +48,6 @@ func (sm SecondMenuSlice) Less(i, j int) bool {
|
||||
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
|
||||
@@ -208,9 +199,3 @@ func UpdateSecondMenu(secondMenu SecondMenuInfo) {
|
||||
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
|
||||
}
|
@@ -11,6 +11,7 @@ package models
|
||||
|
||||
import (
|
||||
"boss/common"
|
||||
"boss/models/accounts"
|
||||
"boss/utils"
|
||||
"context"
|
||||
"errors"
|
||||
@@ -25,7 +26,7 @@ func OperatorAccount(accountUid, operatorType string, amount float64) (string, b
|
||||
if err := o.DoTx(func(ctx context.Context, txOrm orm.TxOrmer) error {
|
||||
|
||||
//处理事务
|
||||
accountInfo := new(AccountInfo)
|
||||
accountInfo := new(accounts.AccountInfo)
|
||||
if err := txOrm.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)
|
||||
return err
|
||||
@@ -65,7 +66,7 @@ func OperatorAccount(accountUid, operatorType string, amount float64) (string, b
|
||||
return err
|
||||
}
|
||||
//往account_history表中插入一条动账记录
|
||||
accountHistory := AccountHistoryInfo{AccountUid: accountUid, AccountName: accountInfo.AccountName, Type: operatorType,
|
||||
accountHistory := accounts.AccountHistoryInfo{AccountUid: accountUid, AccountName: accountInfo.AccountName, Type: operatorType,
|
||||
Amount: amount, Balance: accountInfo.Balance, CreateTime: utils.GetBasicDateTime(), UpdateTime: utils.GetBasicDateTime()}
|
||||
|
||||
if _, err := txOrm.Insert(&accountHistory); err != nil {
|
||||
|
@@ -7,7 +7,7 @@
|
||||
** @Last Modified time: 2019/8/9 14:02
|
||||
** @Software: GoLand
|
||||
****************************************************/
|
||||
package models
|
||||
package user
|
||||
|
||||
import (
|
||||
"github.com/beego/beego/v2/client/orm"
|
Reference in New Issue
Block a user