Skip to content

Commit

Permalink
Merge branch 'price' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
scorpiotzh committed Sep 19, 2023
2 parents 1ffe6b9 + 0acf321 commit f5c9f15
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
14 changes: 13 additions & 1 deletion dao/t_smt_record_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,19 @@ func (d *DbDao) FindSmtRecordInfoByActions(parentAccountId string, actions, subA

func (d *DbDao) GetSmtRecordManualMintYears(parentAccountId string) (total uint64, err error) {
err = d.db.Model(&tables.TableSmtRecordInfo{}).Select("IFNULL(sum(register_years+renew_years),0)").
Where("parent_account_id=? and mint_type in (?) and sub_action in (?) and record_type=?",
Where("parent_account_id=? and mint_type in (?) and sub_action in (?) and record_type=? and quote=0",
parentAccountId, []tables.MintType{tables.MintTypeDefault, tables.MintTypeManual},
[]common.DasAction{common.SubActionCreate, common.SubActionRenew}, tables.RecordTypeChain).Scan(&total).Error
if err == gorm.ErrRecordNotFound {
err = nil
}
return
}

func (d *DbDao) GetSmtRecordManualCKB(parentAccountId string) (total uint64, err error) {
err = d.db.Model(&tables.TableSmtRecordInfo{}).
Select("sum(round(990000/quote,0)*(register_years+renew_years))").
Where("parent_account_id=? and mint_type in (?) and sub_action in (?) and record_type=? and quote>0",
parentAccountId, []tables.MintType{tables.MintTypeDefault, tables.MintTypeManual},
[]common.DasAction{common.SubActionCreate, common.SubActionRenew}, tables.RecordTypeChain).Scan(&total).Error
if err == gorm.ErrRecordNotFound {
Expand Down
9 changes: 7 additions & 2 deletions http_server/handle/statistical_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,14 @@ func (h *HttpHandle) doStatisticalInfo(req *ReqStatisticalInfo, apiResp *api_cod
total, err := h.DbDao.GetSmtRecordManualMintYears(accountId)
if err != nil {
apiResp.ApiRespErr(api_code.ApiCodeDbError, "db error")
return err
return fmt.Errorf("GetSmtRecordManualMintYears err: %s", err.Error())
}
total2, err := h.DbDao.GetSmtRecordManualCKB(accountId)
if err != nil {
apiResp.ApiRespErr(api_code.ApiCodeDbError, "db error")
return fmt.Errorf("GetSmtRecordManualCKB err: %s", err.Error())
}
resp.CkbSpending.Total = fmt.Sprintf("%d", total)
resp.CkbSpending.Total = fmt.Sprintf("%d", total+total2)
return nil
})

Expand Down

0 comments on commit f5c9f15

Please sign in to comment.