DengBiao hace 10 meses
padre
commit
3374ee54b5
Se han modificado 2 ficheros con 38 adiciones y 18 borrados
  1. +23
    -8
      app/admin/svc/svc_data_statisstics.go
  2. +15
    -10
      app/db/db_central_kitchen_for_school_user_with_day.go

+ 23
- 8
app/admin/svc/svc_data_statisstics.go Ver fichero

@@ -1054,7 +1054,8 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD
}

count, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNo(
v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum.CentralKitchenForSchoolUserWithDayStateForCancel,
v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo,
enum.CentralKitchenForSchoolUserWithDayStateForCancel, enum.CentralKitchenForSchoolUserWithDayStateForCanceling,
req.StartDate, req.EndDate, req.MealKindList)
if err2 != nil {
logx.Error(err)
@@ -1267,7 +1268,8 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD
}

count, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNo(
v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum.CentralKitchenForSchoolUserWithDayStateForCancel,
v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo,
enum.CentralKitchenForSchoolUserWithDayStateForCancel, enum.CentralKitchenForSchoolUserWithDayStateForCanceling,
req.StartDate, req.EndDate, req.MealKindList)
if err2 != nil {
logx.Error(err)
@@ -1904,7 +1906,8 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD
list[v.Enterprise.Name] = map[string]int64{}
}
count, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNo(
v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, enum.CentralKitchenForSchoolUserWithDayStateForCancel,
v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo,
enum.CentralKitchenForSchoolUserWithDayStateForCancel, enum.CentralKitchenForSchoolUserWithDayStateForCanceling,
req.StartDate, req.EndDate, req.MealKindList)
if err2 != nil {
logx.Error(err)
@@ -1914,7 +1917,11 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD

for _, value := range req.MealKindList {
if value == enum.CentralKitchenForSchoolUserWithDayKindForBreakfast {
count1, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, req.StartDate, req.EndDate, enum.CentralKitchenForSchoolUserWithDayKindForBreakfast, enum.CentralKitchenForSchoolUserWithDayStateForCancel)
count1, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, req.StartDate,
req.EndDate, enum.CentralKitchenForSchoolUserWithDayKindForBreakfast,
enum.CentralKitchenForSchoolUserWithDayStateForCancel,
enum.CentralKitchenForSchoolUserWithDayStateForCanceling,
)
if err2 != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error())
@@ -1923,7 +1930,11 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD
list[v.Enterprise.Name][enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForBreakfast).String()] += count1
}
if value == enum.CentralKitchenForSchoolUserWithDayKindForLunch {
count2, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, req.StartDate, req.EndDate, enum.CentralKitchenForSchoolUserWithDayKindForLunch, enum.CentralKitchenForSchoolUserWithDayStateForCancel)
count2, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, req.StartDate, req.EndDate,
enum.CentralKitchenForSchoolUserWithDayKindForLunch,
enum.CentralKitchenForSchoolUserWithDayStateForCancel,
enum.CentralKitchenForSchoolUserWithDayStateForCanceling,
)
if err2 != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error())
@@ -1932,7 +1943,11 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD
list[v.Enterprise.Name][enum.CentralKitchenForSchoolUserWithDayKind(enum.CentralKitchenForSchoolUserWithDayKindForLunch).String()] += count2
}
if value == enum.CentralKitchenForSchoolUserWithDayKindForDinner {
count3, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, req.StartDate, req.EndDate, enum.CentralKitchenForSchoolUserWithDayKindForDinner, enum.CentralKitchenForSchoolUserWithDayStateForCancel)
count3, err2 := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(v.CentralKitchenForSchoolPackageOrdForReserve.OutTradeNo, req.StartDate, req.EndDate,
enum.CentralKitchenForSchoolUserWithDayKindForDinner,
enum.CentralKitchenForSchoolUserWithDayStateForCancel,
enum.CentralKitchenForSchoolUserWithDayStateForCanceling,
)
if err2 != nil {
logx.Error(err)
println("<<<<SelfSupportForSchoolDataStatisticsExport3>>>>>Error:::", err.Error())
@@ -2006,13 +2021,13 @@ func CentralKitchenForSchoolDataStatisticsExport(req md.CentralKitchenForSchoolD
dateName := date.Format("2006-01-02")
dates = append(dates, dateName)
for _, vv := range req.MealKindList {
tmpSum, err := centralKitchenForSchoolUserWithDayDb.SumCentralKitchenForSchoolUserWithDayByKind(req.EnterpriseId, dateName, dateName, vv, enum.CentralKitchenForSchoolUserWithDayStateForCancel)
tmpSum, err := centralKitchenForSchoolUserWithDayDb.SumCentralKitchenForSchoolUserWithDayByKind(req.EnterpriseId, dateName, dateName, vv, enum.CentralKitchenForSchoolUserWithDayStateForCancel, enum.CentralKitchenForSchoolUserWithDayStateForCanceling)
if err != nil {
logx.Error(err)
println("<<<<CentralKitchenForSchoolDataStatisticsExport9>>>>>Error:::", err.Error())
panic(err)
}
tmpCount, err := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByKind(req.EnterpriseId, dateName, dateName, vv, enum.CentralKitchenForSchoolUserWithDayStateForCancel)
tmpCount, err := centralKitchenForSchoolUserWithDayDb.CountCentralKitchenForSchoolUserWithDayByKind(req.EnterpriseId, dateName, dateName, vv, enum.CentralKitchenForSchoolUserWithDayStateForCancel, enum.CentralKitchenForSchoolUserWithDayStateForCanceling)
if err != nil {
logx.Error(err)
println("<<<<CentralKitchenForSchoolDataStatisticsExport9>>>>>Error:::", err.Error())


+ 15
- 10
app/db/db_central_kitchen_for_school_user_with_day.go Ver fichero

@@ -79,12 +79,12 @@ func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb
return resp, nil
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByOrdNo(ordNo string, state int, startDate, endDate string, kindList []int) (count int64, err error) {
func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByOrdNo(ordNo string, state1, state2 int, startDate, endDate string, kindList []int) (count int64, err error) {
var m model.CentralKitchenForSchoolUserWithDay
sDate, _ := time.ParseInLocation("2006-01-02 15:04:05", startDate, time.Local)
eDate, _ := time.ParseInLocation("2006-01-02 15:04:05", endDate, time.Local)

count, err = centralKitchenForSchoolUserWithDayDb.Db.Where("ord_no =?", ordNo).And("state !=?", state).
count, err = centralKitchenForSchoolUserWithDayDb.Db.Where("ord_no =?", ordNo).And("state !=?", state1).And("state !=?", state2).
And("date >= ?", sDate.Format("2006-01-02")).And("date <= ?", eDate.Format("2006-01-02")).
In("kind", kindList).
Count(&m)
@@ -100,45 +100,50 @@ func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb
return count, nil
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(ordNo, startDate, endDate string, kind, state int) (count int64, err error) {
func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByOrdNoAndKind(ordNo, startDate, endDate string, kind, state1, state2 int) (count int64, err error) {
var m model.CentralKitchenForSchoolUserWithDay
sDate, _ := time.ParseInLocation("2006-01-02 15:04:05", startDate, time.Local)
eDate, _ := time.ParseInLocation("2006-01-02 15:04:05", endDate, time.Local)

count, err = centralKitchenForSchoolUserWithDayDb.Db.Where("ord_no =?", ordNo).And("kind =?", kind).
And("date >= ?", sDate.Format("2006-01-02")).And("date <= ?", eDate.Format("2006-01-02")).
And("state !=?", state).
And("state !=?", state1).
And("state !=?", state2).
Count(&m)
return count, nil
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) SumCentralKitchenForSchoolUserWithDayByKind(enterpriseId int, startDate, endDate string, kind, state int) (sum float64, err error) {
func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) SumCentralKitchenForSchoolUserWithDayByKind(enterpriseId int, startDate, endDate string, kind, state1, state2 int) (sum float64, err error) {
var m model.CentralKitchenForSchoolUserWithDay
if enterpriseId != 0 {
sum, err = centralKitchenForSchoolUserWithDayDb.Db.Where("kind =?", kind).
And("date >= ?", startDate).And("date <= ?", endDate).And("enterprise_id =?", enterpriseId).
And("state !=?", state).
And("state !=?", state1).
And("state !=?", state2).
Sum(&m, "amount")
} else {
sum, err = centralKitchenForSchoolUserWithDayDb.Db.Where("kind =?", kind).
And("date >= ?", startDate).And("date <= ?", endDate).
And("state !=?", state).
And("state !=?", state1).
And("state !=?", state2).
Sum(&m, "amount")
}
return sum, nil
}

func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByKind(enterpriseId int, startDate, endDate string, kind, state int) (sum int64, err error) {
func (centralKitchenForSchoolUserWithDayDb *CentralKitchenForSchoolUserWithDayDb) CountCentralKitchenForSchoolUserWithDayByKind(enterpriseId int, startDate, endDate string, kind, state1, state2 int) (sum int64, err error) {
var m model.CentralKitchenForSchoolUserWithDay
if enterpriseId != 0 {
sum, err = centralKitchenForSchoolUserWithDayDb.Db.Where("kind =?", kind).
And("date >= ?", startDate).And("date <= ?", endDate).And("enterprise_id =?", enterpriseId).
And("state !=?", state).
And("state !=?", state1).
And("state !=?", state2).
Count(&m)
} else {
sum, err = centralKitchenForSchoolUserWithDayDb.Db.Where("kind =?", kind).
And("date >= ?", startDate).And("date <= ?", endDate).
And("state !=?", state).
And("state !=?", state1).
And("state !=?", state2).
Count(&m)
}
return sum, nil


Cargando…
Cancelar
Guardar