This commit is contained in:
jiangyong 2024-04-30 22:36:41 +08:00
parent fbe90567d5
commit 8b6fca419b
2 changed files with 31 additions and 2 deletions

View File

@ -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
}

View File

@ -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))
}
}