Skip to content

Commit 624d587

Browse files
committed
fix problems
1 parent 011cc9b commit 624d587

3 files changed

Lines changed: 22 additions & 33 deletions

File tree

service/bean/bean.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,15 +173,15 @@ type BlockBean struct {
173173
}
174174

175175
type RecordNumLog struct {
176-
ID bson.ObjectId `bson:"_id,omitempty"`
177-
TxNum int `bson:"tx_num"`
178-
TxAmount int `bson:"tx_amount"`
179-
RequirementNum int `bson:"requirement_num"`
180-
AssetNum int `bson:"asset_num"`
181-
AccountNum int `bson:"account_num"`
182-
Date string `bson:"date"`
183-
Timestamp int `bson:"timestamp"`
184-
CreatedAt time.Time `bson:"createdAt"`
176+
ID bson.ObjectId `bson:"_id,omitempty"`
177+
TxNum int `bson:"tx_num"`
178+
TxAmount uint64 `bson:"tx_amount"`
179+
RequirementNum int `bson:"requirement_num"`
180+
AssetNum int `bson:"asset_num"`
181+
AccountNum int `bson:"account_num"`
182+
Date string `bson:"date"`
183+
Timestamp int `bson:"timestamp"`
184+
CreatedAt time.Time `bson:"createdAt"`
185185
}
186186

187187

service/dashboard/main.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ func (u *Dashboard) GetTxAmountByDay(ctx context.Context, req *dashboard_proto.G
275275
timeSlice :=getRecent7DayTimeSlice()
276276
log.Info(timeSlice)
277277
var ret []bean.TxBean
278-
var ret2 []bean.AssetBean
278+
var ret2 bean.AssetBean
279279
var amount uint64 = 0
280280
var data []*dashboard_proto.TxAmountByDay
281281
var mgo = mgo.Session()
@@ -289,17 +289,10 @@ func (u *Dashboard) GetTxAmountByDay(ctx context.Context, req *dashboard_proto.G
289289
if err!= nil {
290290
log.Error(err)
291291
}
292-
var assetIdArr []string;
293-
for _, v := range ret {
294-
assetIdArr = append(assetIdArr, v.Data.BasicInfo.AssetID)
295-
}
296292

297-
log.Info(assetIdArr)
298-
299-
mgo.DB(config.DB_NAME).C("Messages").Find(bson.M{"type": "assetreg", "data.asset_id": bson.M{"$in": assetIdArr}}).All(&ret2)
300-
for _, v := range ret2 {
301-
log.Info(v.Data.BasicInfo.Price)
302-
amount += v.Data.BasicInfo.Price
293+
for _, v := range ret {
294+
mgo.DB(config.DB_NAME).C("Messages").Find(bson.M{"type": "assetreg", "data.asset_id": v.Data.BasicInfo.AssetID}).One(&ret2)
295+
amount += ret2.Data.BasicInfo.Price
303296
}
304297

305298
log.Info(amount)
@@ -316,7 +309,8 @@ func (u *Dashboard) GetTxAmountByDay(ctx context.Context, req *dashboard_proto.G
316309
}
317310

318311
func (u *Dashboard) GetAllTypeTotal(ctx context.Context, req *dashboard_proto.GetAllTypeTotalRequest, rsp *dashboard_proto.GetAllTypeTotalResponse) error {
319-
var accountNum, assetNum, requirementNum, txAmount, txNum int= 0, 0, 0, 0, 0
312+
var accountNum, assetNum, requirementNum, txNum int= 0, 0, 0, 0
313+
var txAmount uint64 = 0
320314
min, max := query.TodayTimeSolt()
321315
accountNum = accountNum + query.AccountNum(min, max)
322316
assetNum = assetNum + query.AssetNum(min, max)

service/query/query.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ func TxNum(min int64, max int64) int {
2525
return count
2626
}
2727

28-
func TxAmount(min int64, max int64) int {
29-
var amount int = 0
28+
func TxAmount(min int64, max int64) uint64 {
29+
var amount uint64 = 0
3030
var ret []bean.TxBean
31-
var ret2 []bean.AssetBean
31+
var ret2 bean.AssetBean
3232

3333
var mgo = mgo.Session()
3434
defer mgo.Close()
@@ -39,17 +39,12 @@ func TxAmount(min int64, max int64) int {
3939
if err!= nil {
4040
log.Error(err)
4141
}
42-
var assetIdArr []string;
42+
4343
for _, v := range ret {
44-
assetIdArr = append(assetIdArr, v.Data.BasicInfo.AssetID)
45-
}
46-
log.Info(len(assetIdArr))
47-
mgo.DB(config.DB_NAME).C("Messages").Find(bson.M{"type": "assetreg", "data.asset_id": bson.M{"$in": assetIdArr}}).All(&ret2)
48-
for _, v := range ret2 {
49-
amount += int(v.Data.BasicInfo.Price)
44+
mgo.DB(config.DB_NAME).C("Messages").Find(bson.M{"type": "assetreg", "data.asset_id": v.Data.BasicInfo.AssetID}).One(&ret2)
45+
amount += ret2.Data.BasicInfo.Price
5046
}
51-
log.Info(amount)
52-
log.Info(TimestampToUTC(max))
47+
5348
return amount
5449
}
5550

0 commit comments

Comments
 (0)