From 8d0669fc2f98e8abf89193ee6bbd67e397e75adb Mon Sep 17 00:00:00 2001 From: jiangyong27 Date: Sat, 29 Mar 2025 16:16:58 +0800 Subject: [PATCH] totalOrder --- common/dao/external_corp_order.go | 5 +++-- service/salary_calculator/salary_calculator_1002.go | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common/dao/external_corp_order.go b/common/dao/external_corp_order.go index 7450bfe..b5fcbc7 100644 --- a/common/dao/external_corp_order.go +++ b/common/dao/external_corp_order.go @@ -23,9 +23,11 @@ func (d *ExternalCorpOrder) QueryOwnerOrder(owner string, startTime, endTime int var o []*model.ExternalCorpOrder + if owner != "" { + tx.Where("cp_user.username = ?", owner) + } tx.Where(orderTable+".status = ?", 2) - tx.Where("cp_user.username = ?", owner) tx.Where(orderTable+".pay_time >= ?", startTime) tx.Where(orderTable+".pay_time <= ?", endTime) @@ -48,7 +50,6 @@ func (d *ExternalCorpOrder) QueryProcessOrder(owner string, startTime, endTime i var o []*model.ExternalCorpOrder tx.Where(orderTable+".process_status = ?", 2) - tx.Where("cp_user.username = ?", owner) tx.Where(orderTable+".pay_time >= ?", startTime) tx.Where(orderTable+".pay_time <= ?", endTime) diff --git a/service/salary_calculator/salary_calculator_1002.go b/service/salary_calculator/salary_calculator_1002.go index 00e47f4..297fe34 100644 --- a/service/salary_calculator/salary_calculator_1002.go +++ b/service/salary_calculator/salary_calculator_1002.go @@ -31,8 +31,12 @@ func (s *SalaryCalculator1002) Calculate(salary *model.StaffSalary) map[string]i if err != nil { log.Errorf("db error:%s", err.Error()) } - + totalOrders, err := dao.NewExternalCorpOrder().QueryOwnerOrder("", startTime, endTime) + if err != nil { + log.Errorf("db error:%s", err.Error()) + } data["orderNum"] = len(orders) + data["totalOrderNum"] = len(totalOrders) //2.处理的订单 processOrders, err := dao.NewExternalCorpOrder().QueryProcessOrder(s.user.Username, startTime, endTime)