This commit is contained in:
aozhiwei 2024-06-27 17:33:42 +08:00
parent 9bf2ebc44c
commit f8063b5003
7 changed files with 30 additions and 3 deletions

View File

@ -8,3 +8,6 @@ type TaskMgr interface {
LockOpenGodBullion() LockOpenGodBullion()
UnLockOpenGodBullion() UnLockOpenGodBullion()
} }
type ServiceMgr interface {
}

View File

@ -14,6 +14,7 @@ const (
const ( const (
APP_MODULE_IDX = iota APP_MODULE_IDX = iota
TASK_MGR_MODULE_IDX TASK_MGR_MODULE_IDX
SERVICE_MGR_MODULE_IDX
MAX_MODULE_IDX MAX_MODULE_IDX
) )

View File

@ -10,10 +10,12 @@ import (
var modules [constant.MAX_MODULE_IDX]q5.Module var modules [constant.MAX_MODULE_IDX]q5.Module
var initOrders = []int32{ var initOrders = []int32{
constant.TASK_MGR_MODULE_IDX, constant.TASK_MGR_MODULE_IDX,
constant.SERVICE_MGR_MODULE_IDX,
} }
var app common.App var app common.App
var taskMgr common.TaskMgr var taskMgr common.TaskMgr
var serviceMgr common.ServiceMgr
func GetApp() common.App { func GetApp() common.App {
return app return app
@ -34,6 +36,10 @@ func RegModule(idx int32, m q5.Module) {
{ {
taskMgr = m.(common.TaskMgr) taskMgr = m.(common.TaskMgr)
} }
case constant.SERVICE_MGR_MODULE_IDX:
{
serviceMgr = m.(common.ServiceMgr)
}
default: default:
{ {
panic("unknow module") panic("unknow module")

View File

@ -1,7 +1,13 @@
package service package service
import (
"main/constant"
"main/global"
)
var BcCurrency = new(bcCurrency) var BcCurrency = new(bcCurrency)
var _serviceMgr = new(serviceMgr)
func init() { func init() {
BcCurrency.init() global.RegModule(constant.SERVICE_MGR_MODULE_IDX, _serviceMgr)
} }

View File

@ -0,0 +1,11 @@
package service
type serviceMgr struct {
}
func (this *serviceMgr) Init() {
BcCurrency.init()
}
func (this *serviceMgr) UnInit() {
}

View File

@ -68,7 +68,7 @@ func (this* repairOrder) repairPrice(ds *f5.DataSet) bool {
srcPriceItemType = p.Data.Buy[0].ItemType srcPriceItemType = p.Data.Buy[0].ItemType
} }
srcPriceExchangeRate, price := service.BcCurrency.ExchangeUSD( srcPriceExchangeRate, price := service.BcCurrency.ExchangeUSD(
srcPriceAmount, srcPriceContractAddress, srcPriceItemType) srcPriceAmount, srcPriceItemType, srcPriceContractAddress)
updateFields := [][]string{ updateFields := [][]string{
{"src_price_amount", srcPriceAmount}, {"src_price_amount", srcPriceAmount},
{"src_price_contract_address", srcPriceContractAddress}, {"src_price_contract_address", srcPriceContractAddress},

View File

@ -140,7 +140,7 @@ func (this* webHook) orderUpdatedCb(ds *f5.DataSet) bool {
srcPriceContractAddress := p.Data.Buy[0].ContractAddress srcPriceContractAddress := p.Data.Buy[0].ContractAddress
srcPriceItemType := p.Data.Buy[0].ItemType srcPriceItemType := p.Data.Buy[0].ItemType
srcPriceExchangeRate, price := service.BcCurrency.ExchangeUSD( srcPriceExchangeRate, price := service.BcCurrency.ExchangeUSD(
srcPriceAmount, srcPriceContractAddress, srcPriceItemType) srcPriceAmount, srcPriceItemType, srcPriceContractAddress)
commonFields := [][]string{ commonFields := [][]string{
{"order_id", p.Data.Id}, {"order_id", p.Data.Id},
{"chain", p.Chain}, {"chain", p.Chain},