forked from JointCloud/pcm-coordinator
数据上链提交金额
This commit is contained in:
parent
cdff8aeb0c
commit
84540521b6
|
@ -145,6 +145,14 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// 查询资源价格
|
||||
var price int64
|
||||
for _, clusterId := range req.ClusterIds {
|
||||
var clusterPrice int64
|
||||
l.svcCtx.DbEngin.Raw("select price from resource_cost where resource_id = ?", clusterId).Scan(&clusterPrice)
|
||||
price = price + clusterPrice
|
||||
}
|
||||
|
||||
remoteUtil.Evidence(remoteUtil.EvidenceParam{
|
||||
UserIp: req.UserIp,
|
||||
Url: l.svcCtx.Config.BlockChain.Url,
|
||||
|
@ -152,6 +160,7 @@ func (l *CommitGeneralTaskLogic) CommitGeneralTask(req *types.GeneralTaskReq) er
|
|||
FunctionName: l.svcCtx.Config.BlockChain.FunctionName,
|
||||
Type: l.svcCtx.Config.BlockChain.Type,
|
||||
Token: req.Token,
|
||||
Amount: price,
|
||||
Args: []string{strconv.FormatInt(taskModel.Id, 10), string(bytes)},
|
||||
})
|
||||
return nil
|
||||
|
|
|
@ -113,6 +113,10 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
|
|||
JobId: string(""),
|
||||
}
|
||||
// 数据上链
|
||||
// 查询资源价格
|
||||
var price int64
|
||||
l.svcCtx.DbEngin.Raw("select price from resource_cost where resource_id = ?", clusterId).Scan(&price)
|
||||
|
||||
bytes, _ := json.Marshal(taskModel)
|
||||
remoteUtil.Evidence(remoteUtil.EvidenceParam{
|
||||
UserIp: req.UserIp,
|
||||
|
@ -121,6 +125,7 @@ func (l *CommitHpcTaskLogic) CommitHpcTask(req *types.CommitHpcTaskReq) (resp *t
|
|||
FunctionName: l.svcCtx.Config.BlockChain.FunctionName,
|
||||
Type: l.svcCtx.Config.BlockChain.Type,
|
||||
Token: req.Token,
|
||||
Amount: price,
|
||||
Args: []string{strconv.FormatInt(taskModel.Id, 10), string(bytes)},
|
||||
})
|
||||
// 提交job到指定集群
|
||||
|
|
|
@ -14,6 +14,7 @@ type EvidenceParam struct {
|
|||
Args []string `json:"args"`
|
||||
Token string `json:"token"`
|
||||
UserIp string `json:"userIp"`
|
||||
Amount int64 `json:"amount"`
|
||||
}
|
||||
|
||||
func Evidence(EvidenceParam EvidenceParam) error {
|
||||
|
|
Loading…
Reference in New Issue