Browse Source

FIX:首页数据统计 待派单 配送中

zoie 10 months ago
parent
commit
3273154993
2 changed files with 13 additions and 8 deletions
  1. 9 8
      app/admin/service/dto/waybill.go
  2. 4 0
      app/admin/service/waybill.go

+ 9 - 8
app/admin/service/dto/waybill.go

@@ -203,14 +203,15 @@ type WaybillStatsReq struct {
 }
 
 type WaybillStatsRes struct {
-	TodayNum       int64 `json:"todayNum"`       // 今日总运单数
-	WaitTruckNum   int64 `json:"waitTruckNum"`   // 未装车
-	WaitStorageNum int64 `json:"waitStorageNum"` // 未入库
-	InDeliveryNum  int64 `json:"inDeliveryNum"`  // 运送中
-	ThisMonthNum   int64 `json:"thisMonthNum"`   // 本月运单数
-	LastMonthNum   int64 `json:"lastMonthNum"`   // 上月运单数
-	ThisYearNum    int64 `json:"thisYearNum"`    // 本年运单数
-	LastYearNum    int64 `json:"lastYearNum"`    // 上年运单数
+	TodayNum        int64 `json:"todayNum"`        // 今日总运单数
+	WaitDeliveryNum int64 `json:"waitDeliveryNum"` // 待派单
+	WaitTruckNum    int64 `json:"waitTruckNum"`    // 未装车
+	WaitStorageNum  int64 `json:"waitStorageNum"`  // 未入库
+	InDeliveryNum   int64 `json:"inDeliveryNum"`   // 运送中
+	ThisMonthNum    int64 `json:"thisMonthNum"`    // 本月运单数
+	LastMonthNum    int64 `json:"lastMonthNum"`    // 上月运单数
+	ThisYearNum     int64 `json:"thisYearNum"`     // 本年运单数
+	LastYearNum     int64 `json:"lastYearNum"`     // 上年运单数
 
 	Stats []struct {
 		Date string `json:"date"` // 日期 2024-01-01

+ 4 - 0
app/admin/service/waybill.go

@@ -1061,10 +1061,14 @@ func (e *Waybill) GetBasicsStats(c *dto.WaybillStatsReq, p *actions.DataPermissi
 
 	// 今日总运单数
 	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("order_time between ? and ?", todayStartTime, todayEndTime).Count(&res.TodayNum)
+	// 待派单
+	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusWaitDelivery).Count(&res.WaitDeliveryNum)
 	// 未装车
 	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusWaitTruck).Count(&res.WaitTruckNum)
 	// 未入库
 	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status = ?", model.WaybillStatusWaitStorage).Count(&res.WaitStorageNum)
+	// 配送中
+	e.Orm.Model(&data).Scopes(actions.Permission(data.TableName(), p)).Where("status in (?)", []int{model.WaybillStatusTruck, model.WaybillStatusStorage, model.WaybillStatusTruckOut, model.WaybillStatusStorageOut}).Count(&res.InDeliveryNum)
 	// 获取本月,上月数据
 	e.Orm.Model(&data).Select("date_format(order_time,'%Y%m') date,count(1) as count ").Scopes(actions.Permission(data.TableName(), p)).
 		Where("order_time between ? and ?", monthStartTime, now).Group("date").Find(&monthCount)