diff --git a/dao/nowcar.go b/dao/nowcar.go index b57fe9c..e027f1e 100644 --- a/dao/nowcar.go +++ b/dao/nowcar.go @@ -66,3 +66,25 @@ func (d *NowCarDao) GetBusy(shopName, workstation string) (*model.Nowcar, error) } return &u, nil } + +func (d *NowCarDao) QueryToday(shopName, workstation, day string) ([]*model.Nowcar, error) { + var u []*model.Nowcar + tx := global.GetDB().Table(d.TableName()) + + tx = tx.Where("shop_name = ?", shopName) + tx = tx.Where("workstation = ?", workstation) + tx = tx.Where("day = ?", day) + tx = tx.Where("start_time != 0") + tx = tx.Where("end_time != 0") + + tx = tx.Order("start_time DESC") + res := tx.Find(&u) + if res.Error == gorm.ErrRecordNotFound { + return nil, nil + } + + if res.Error != nil { + return nil, res.Error + } + return u, nil +} diff --git a/worker/nowcar/nowcar.go b/worker/nowcar/nowcar.go index 9ac8a85..6a20b6c 100644 --- a/worker/nowcar/nowcar.go +++ b/worker/nowcar/nowcar.go @@ -95,10 +95,17 @@ func getInfo(devId string) ([]string, error) { log.Errorf("db error :%s", err.Error()) continue } + + todays, err := dao.NewNowCarDao().QueryToday(shopName, workstation, time.Now().Format("2006-01-02")) + totalAmount := int64(0) + for _, day := range todays { + totalAmount += day.Amount + } //订单完成提示 - log.Errorf("shopName=%s workstation=%s time=[%s],cost=%d,money=%s", + log.Errorf("shopName=%s,workstation=%s,time=[%s],cost_minute=%d,money=%s,total=[%s/%d]", m2.ShopName, m2.Workstation, goutil.TimeToDateTime(m2.StartTime), - (m2.EndTime-m2.StartTime)/60, goutil.FormatMoney(m2.Amount)) + (m2.EndTime-m2.StartTime)/60, goutil.FormatMoney(m2.Amount), + goutil.FormatMoney(totalAmount), len(todays)) } }